How to cherrypick for other branch's commit

1. git remote add stream_name repository

    e.g.) git remote add upstream git@bitbucket.org:testorg/test_1.0.git

2. git remote -v

           upstream        git@bitbucket.org:testorg/test_1.0.git (fetch)
           upstream        git@bitbucket.org:testorg/test_1.0.git (push)

3. git fetch upstream #branch_name

    e.g.) git fetch upstream dev/epic-1

4. git cherry-pick -e #commit

5. git push

6. git remove remove upstream

반응형

android.support.design.widget.TabLayout 와 android.support.v4.view.ViewPager 추가가 안되는 문제는 AndroidX로 변경되었기 때문임

com.google.android.material.tabs.TabLayout와 androidx.viewpager.widget.ViewPager로 변경

 

 

아래 녀석들도 변경이 필요함

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.FragmentPagerAdapter;

 

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

 

그런데 FragmentPagerAdapter class는 deplicated되었지만 사용은 가능함

 

반응형

'TinyProjects' 카테고리의 다른 글

Git | Tips  (1) 2024.02.26
Using WebCam with Syntek driver from Ubuntu  (0) 2016.03.22
Beautiful KiWi with Python and OpenCV  (0) 2016.03.17
LCD1602 모듈과 아두이노  (0) 2016.03.13
HC-SR04 초음파 센서와 아두이노  (1) 2016.03.11

Using WebCam with Syntek driver from Ubuntu


After installing Ubuntu in my old laptop, with unknown reason, embeded Webcam was not able to use.

 



The USB connection was okay as 'Syntek Web Cam'.

Linux kjpark-F9SG 4.2.0-34-generic #39-Ubuntu SMP Thu Mar 10 22:11:49 UTC 2016 i686 i686 i686 GNU/Linux

root@kjpark-F9SG:~/syntek/syntek/driver# lsusb
Bus 002 Device 005: ID 0bda:0116 Realtek Semiconductor Corp. RTS5116 Card Reader Controller
Bus 002 Device 003: ID 174f:6a33 Syntek Web Cam - Asus F3SA, F9J, F9S
Bus 002 Device 002: ID 05ac:12a8 Apple, Inc. iPhone5/5C/5S/6
Bus 002 Device 006: ID 05ac:12a0 Apple, Inc. iPhone 4S
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 007 Device 002: ID 0b05:1712 ASUSTek Computer, Inc. BT-183 Bluetooth 2.0+EDR adapter
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


As there is no usb driver for that device, I've downloaded the code from following CVN server and tried to build it.

Out-of-tree GPL driver for stk11xx (by Martin Roos and Nicolas VIVEN) : http://sourceforge.net/projects/syntekdriver/

svn co https://syntekdriver.svn.sourceforge.net/svnroot/syntekdriver/trunk/driver/ syntekdriver


The code seems to be implemented from old linux kernel based. So, there are multiple build errors.

root@kjpark-F9SG:~/syntekdriver# make -f Makefile.standalone

make -C /lib/modules/4.2.0-34-generic/build SUBDIRS=/root/syntekdriver modules
make[1]: Entering directory '/usr/src/linux-headers-4.2.0-34-generic'
  CC [M]  /root/syntekdriver/stk11xx-usb.o
  CC [M]  /root/syntekdriver/stk11xx-v4l.o
/root/syntekdriver/stk11xx-v4l.c: In function ‘v4l_stk11xx_register_video_device’:
/root/syntekdriver/stk11xx-v4l.c:1503:11: error: ‘struct video_device’ has no member named ‘parent’
  dev->vdev->parent = &dev->interface->dev;
           ^
/root/syntekdriver/stk11xx-v4l.c: At top level:
/root/syntekdriver/stk11xx-v4l.c:1553:2: error: unknown field ‘ioctl’ specified in initializer
  .ioctl = v4l_stk11xx_ioctl,
  ^
/root/syntekdriver/stk11xx-v4l.c:1553:11: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
  .ioctl = v4l_stk11xx_ioctl,
           ^
/root/syntekdriver/stk11xx-v4l.c:1553:11: note: (near initialization for ‘v4l_stk11xx_fops.open’)
scripts/Makefile.build:258: recipe for target '/root/syntekdriver/stk11xx-v4l.o' failed
make[2]: *** [/root/syntekdriver/stk11xx-v4l.o] Error 1
Makefile:1398: recipe for target '_module_/root/syntekdriver' failed
make[1]: *** [_module_/root/syntekdriver] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.2.0-34-generic'
Makefile.standalone:13: recipe for target 'driver' failed
make: *** [driver] Error 2


After googling, there are some patches for that error.

https://patchwork.linuxtv.org/patch/19561/

https://patchwork.linuxtv.org/patch/18757/


Even applying the patches, there are build error from bug.h side.

root@kjpark-F9SG:~/syntek/syntek/driver# make -f Makefile.standalone
make -C /lib/modules/4.2.0-34-generic/build SUBDIRS=/root/syntek/syntek/driver modules
make[1]: Entering directory '/usr/src/linux-headers-4.2.0-34-generic'
  CC [M]  /root/syntek/syntek/driver/stk11xx-sysfs.o
In file included from include/linux/thread_info.h:11:0,
                 from ./arch/x86/include/asm/preempt.h:6,
                 from include/linux/preempt.h:64,
                 from include/linux/spinlock.h:50,
                 from include/linux/seqlock.h:35,
                 from include/linux/time.h:5,
                 from include/linux/stat.h:18,
                 from include/linux/module.h:10,
                 from /root/syntek/syntek/driver/stk11xx-sysfs.c:34:
include/linux/bug.h:33:45: error: negative width in bit-field ‘<anonymous>’
 #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
                                             ^
include/linux/kernel.h:829:3: note: in expansion of macro ‘BUILD_BUG_ON_ZERO’
   BUILD_BUG_ON_ZERO((perms) & 2) +     \
   ^
include/linux/sysfs.h:92:12: note: in expansion of macro ‘VERIFY_OCTAL_PERMISSIONS’
    .mode = VERIFY_OCTAL_PERMISSIONS(_mode) },  \
            ^
include/linux/device.h:571:45: note: in expansion of macro ‘__ATTR’
  struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store)
                                             ^
/root/syntek/syntek/driver/stk11xx-sysfs.c:489:8: note: in expansion of macro ‘DEVICE_ATTR’
 static DEVICE_ATTR(brightness, S_IRUGO | S_IWUGO, show_brightness, store_brightness);    /**
        ^
scripts/Makefile.build:258: recipe for target '/root/syntek/syntek/driver/stk11xx-sysfs.o' failed
make[2]: *** [/root/syntek/syntek/driver/stk11xx-sysfs.o] Error 1
Makefile:1398: recipe for target '_module_/root/syntek/syntek/driver' failed
make[1]: *** [_module_/root/syntek/syntek/driver] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.2.0-34-generic'
Makefile.standalone:13: recipe for target 'driver' failed
make: *** [driver] Error 2


For this build error, 'S_IRUGO | S_IWUGO' should be changed to '0660' manually.

https://github.com/torvalds/linux/commit/58f86cc89c3372d3e61d5b71e5513ec5a0b02848

https://github.com/notro/fbtft/issues/165


Now the driver is ready to roll out.


  • modprobe videodev
  • modprobe uvcvideo
  • insmod stk11xx.ko


The modprobe is a tool to add or remove loadable kernel module (LKM). The insmod can load a module which is belong to '/lib/modules/#kernel-version'. Unlike the insmode, modeprobe supports to load available precedent modules which has the dependency.


Example of kernel modules loading realted with USB webcam


modprobe videodev

[ 4468.540163] media: Linux media interface: v0.10
[ 4468.571920] Linux video capture interface: v2.00


root@kjpark-F9SG:/dev# lsmod | grep videodev
videodev              143360  4 uvcvideo,stk11xx,v4l2_common,videobuf2_core
media                  24576  2 uvcvideo,videodev


modprobe uvcvideo

[ 4505.015223] usbcore: registered new interface driver uvcvideo
[ 4505.015227] USB Video Class driver (1.1.1)


root@kjpark-F9SG:/dev# lsmod | grep uvcvideo
uvcvideo               77824  0
videobuf2_vmalloc      16384  1 uvcvideo
videobuf2_core         49152  1 uvcvideo
videodev              143360  4 uvcvideo,stk11xx,v4l2_common,videobuf2_core
media                  24576  2 uvcvideo,videodev

insmod stk11xx.ko

[ 4527.947957] stk11xx: Syntek USB2.0 webcam driver startup
[ 4527.947961] stk11xx: Copyright(c) 2006-2009 Nicolas VIVIEN
[ 4527.947995] stk11xx: Syntek USB2.0 - STK-1135 based webcam found.
[ 4527.947997] stk11xx: Syntek AVStream USB2.0 1.3M WebCam - Product ID 0x6A33.
[ 4527.947999] stk11xx: Release: 0005
[ 4527.948001] stk11xx: Number of interfaces : 1
[ 4527.949481] stk11xx: Initialize USB2.0 Syntek Camera
[ 4528.545121] stk11xx: Syntek USB2.0 Camera is ready
[ 4528.545966] stk11xx: Syntek USB2.0 Camera is now controlling video device /dev/video0
[ 4528.546551] usbcore: registered new interface driver usb_stk11xx_driver
[ 4528.546556] stk11xx: v2.2.0 : Syntek USB Video Camera
[ 4529.358087] stk11xx: Check device return error (0x0201 = 0C) !
[ 4529.360443] stk11xx: Check device return error (0x0201 = 0C) !


root@kjpark-F9SG:/dev# lsmod | grep stk11xx
stk11xx               143360  0
videodev              143360  4 uvcvideo,stk11xx,v4l2_common,videobuf2_core


Finally, a video device will be created as like follow.

root@kjpark-F9SG:/dev# ls -l /dev/video*
crw-rw----+ 1 root video 81, 0  Mar 23 12:37 /dev/video0
root@kjpark-F9SG:/dev#



How to load the kernel module and driver after boot-up


1. Copy the stk11xx.ko to  /lib/modules/`uname -r`/kernel/drivers folder

mkdir /lib/modules/`uname -r`/kernel/drivers/syntek

cp stk11xx.ko /lib/modules/`uname -r`/kernel/drivers/syntek

sync

depmod /lib/modules/`uname -r`/kernel/drivers/syntek/stk11xx.ko

2. Add the required modules to /etc/modules file

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

lp
videodev
uvcvideo
stk11xx

3. After reboot the Ubuntu, check lsmod for stk11xx


References :

https://doc.ubuntu-fr.org/syntek

http://lxr.free-electrons.com/source/include/media/v4l2-dev.h#L37

http://dmaiorino.com/?p=12

반응형

'TinyProjects' 카테고리의 다른 글

Git | Tips  (1) 2024.02.26
Android | studio 4.2.1 library 안 맞는 문제  (0) 2021.06.19
Beautiful KiWi with Python and OpenCV  (0) 2016.03.17
LCD1602 모듈과 아두이노  (0) 2016.03.13
HC-SR04 초음파 센서와 아두이노  (1) 2016.03.11

Next step for Tiny Project is about image processing to recognize KiWi characteristic.


1. recognize a KiWi from a still image

2. Extract the characteristic like aspect ratio, size, and shape as a ideal good product

3. Calculate a score from the data


OpenCV and Python have already provided a simple way for image processing.


1. Make a image blur
2. change the color space to gray
3. extract object based on threshold
4. extract contours
5. decide a biggest object from contours set

6. Extract the characteristics

 

 

 

 

Script result

root@kjpark-F9SG:/home/kjpark/code/Python/imageprocessing# python outline.py
Peri : 1950
Peri : 332
solidity 0.993691436532
virtual ellipse
((346.2395935058594, 585.294677734375), (539.5545043945312, 630.1558837890625), 161.14199829101562)
((346.4705810546875, 592.38232421875), (539.6417846679688, 621.376220703125), -14.03624439239502)
virtual box
[[160 959]
 [  9 356]
 [532 225]
 [683 828]]
aspect ratio
0.918367346939

 

 Examplel of Image Processing

 

 

 

 

Example Python Source code

https://bitbucket.org/ThereSedew99/codes/raw/48c87ac2b77b9b6adb58dffa9f5724a54341b78c/Python/imageprocessing/outline.py


 


 

Refernces :

http://embedonix.com/articles/image-processing/installing-opencv-3-1-0-on-ubuntu/

http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_imgproc/py_contours/py_contour_properties/py_contour_properties.html

http://pythontips.com/2015/03/11/a-guide-to-finding-books-in-images-using-python-and-opencv/

반응형

마지막으로 알아볼 녀석은 LCD1602 모듈입니다.




우선 datasheet를 먼저 보려고.. 했으나... ㅎㄷㄷ


http://www.elecrow.com/download/LCD1602.pdf



PIN map을 확인하여 arduino에 연결을 적절히(?) 해주세요. Ground를 특히 주의하셔야 합니다.


다행히 LCD library가 Arduino에서 제공되고 있어, Datasheet의 Initialization Sequence 정도 참고로 보시면 될듯합니다.





가난한 S/W 쟁이라 아무생각 없이 우선 cable들만 연결해서 동작이 되는지 확인해 보았습니다.



하지만 접지에 문제가 있는지 제대로 동작하지 않는 ㅠ.ㅠ

접지가 제대로 되지 않아 글자도 깨져 출력 되어 전원 인가된 상태만 확인하였습니다.

아래 사진에 하얀색으로 빵처럼 납작하게 생긴 판은 일명 빵판(bread-board)입니다.




결국 H/W 랩실에 들어가서 정상적으로 PIN head로 납땜을 해주었습니다.


S*-H사에서 갈고 닦은 납땜 실력으로 겨우 겨우 ^^:








/*

  LiquidCrystal Library - Hello World


 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal

 library works with all LCD displays that are compatible with the

 Hitachi HD44780 driver. There are many of them out there, and you

 can usually tell them by the 16-pin interface.


 This sketch prints "Hello World!" to the LCD

 and shows the time.


  The circuit:

 * LCD RS pin to digital pin 12

 * LCD Enable pin to digital pin 11

 * LCD D4 pin to digital pin 5

 * LCD D5 pin to digital pin 4

 * LCD D6 pin to digital pin 3

 * LCD D7 pin to digital pin 2

 * LCD R/W pin to ground

 * LCD VSS pin to ground

 * LCD VCC pin to 5V

 * 10K resistor:

 * ends to +5V and ground

 * wiper to LCD VO pin (pin 3)


 Library originally added 18 Apr 2008

 by David A. Mellis

 library modified 5 Jul 2009

 by Limor Fried (http://www.ladyada.net)

 example added 9 Jul 2009

 by Tom Igoe

 modified 22 Nov 2010

 by Tom Igoe


 This example code is in the public domain.


 http://www.arduino.cc/en/Tutorial/LiquidCrystal

 */


// include the library code:

#include <LiquidCrystal.h>


// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);


void setup() {

  // set up the LCD's number of columns and rows:

  lcd.begin(16, 2);

  // Print a message to the LCD.

  lcd.print("hello, world!");

}


void loop() {

  // set the cursor to column 0, line 1

  // (note: line 1 is the second row, since counting begins with 0):

  lcd.setCursor(0, 1);

  // print the number of seconds since reset:

  lcd.print(millis() / 1000);

}


References :

https://www.arduino.cc/en/Tutorial/HelloWorld?from=Tutorial.LiquidCrystal

http://cafe.naver.com/mpucafe/2863

https://learn.adafruit.com/character-lcds/wiring-a-character-lcd

http://blog.naver.com/q19891204/220605172716

반응형

+ Recent posts