Programming/openCV2015. 9. 28. 23:43

약어정리


SIFT(Scale Invariant Feature Transform)

HOG(Histogram of Oriented Gradient)

Haar

Ferns

LBP(Local Binary Pattern)

MCT(Modified Census Transform)


[링크 : http://darkpgmr.tistory.com/116]


camshift

meanshift

[링크 : http://darkpgmr.tistory.com/111]

opencv

[링크 : http://t9t9.com/37] matchtemplate()


opencv 2

[링크 : http://docs.opencv.org/modules/imgproc/doc/object_detection.html]  matchTemplate

[링크 : http://docs.opencv.org/doc/tutorials/imgproc/histograms/template_matching/template_matching.html] <<

[링크 : http://docs.opencv.org/modules/core/doc/basic_structures.html#mat-copyto]

    [링크 : http://webnautes.tistory.com/584] Mat 클래스 / copyto() clone() 메소드

[링크 : http://thinkpiece.tistory.com/246] SIFT 기반

[링크 : http://thinkpiece.tistory.com/244] haar 기반



$ sudo find / -name haarcascade*

/usr/share/opencv/haarcascades

/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml

/usr/share/opencv/haarcascades/haarcascade_mcs_leftear.xml

/usr/share/opencv/haarcascades/haarcascade_fullbody.xml

/usr/share/opencv/haarcascades/haarcascade_frontalface_alt.xml

/usr/share/opencv/haarcascades/haarcascade_righteye_2splits.xml

/usr/share/opencv/haarcascades/haarcascade_mcs_eyepair_big.xml

/usr/share/opencv/haarcascades/haarcascade_mcs_mouth.xml

/usr/share/opencv/haarcascades/haarcascade_lefteye_2splits.xml

/usr/share/opencv/haarcascades/haarcascade_mcs_lefteye.xml

/usr/share/opencv/haarcascades/haarcascade_profileface.xml

/usr/share/opencv/haarcascades/haarcascade_mcs_nose.xml

/usr/share/opencv/haarcascades/haarcascade_eye_tree_eyeglasses.xml

/usr/share/opencv/haarcascades/haarcascade_mcs_righteye.xml

/usr/share/opencv/haarcascades/haarcascade_mcs_upperbody.xml

/usr/share/opencv/haarcascades/haarcascade_mcs_rightear.xml

/usr/share/opencv/haarcascades/haarcascade_eye.xml

/usr/share/opencv/haarcascades/haarcascade_frontalface_alt2.xml

/usr/share/opencv/haarcascades/haarcascade_upperbody.xml

/usr/share/opencv/haarcascades/haarcascade_mcs_eyepair_small.xml

/usr/share/opencv/haarcascades/haarcascade_frontalface_alt_tree.xml

/usr/share/opencv/haarcascades/haarcascade_lowerbody.xml



'Programming > openCV' 카테고리의 다른 글

openCV 템플릿 매칭 예제 실행  (0) 2015.10.01
opencv 버전들  (0) 2015.09.30
openCV 에피폴라 기하 관련 내용  (0) 2015.09.28
opencv highgui trackbar  (0) 2015.09.27
opencv2 마우스 이벤트 / 클릭 위치  (0) 2015.09.25
Posted by 구차니
Programming/openCV2015. 9. 28. 22:44

동영상에서 실시간으로 연산이 되려나 모르겠네...

그것도 라즈베리로.. 흐음...


SIFT랑 무슨 차이인지 좀 찾아 봐야 할 듯..


[링크 : http://docs.opencv.org/master/da/de9/tutorial_py_epipolar_geometry.html]

'Programming > openCV' 카테고리의 다른 글

opencv 버전들  (0) 2015.09.30
opencv 템플릿 매칭 관련  (0) 2015.09.28
opencv highgui trackbar  (0) 2015.09.27
opencv2 마우스 이벤트 / 클릭 위치  (0) 2015.09.25
opencv2.. VideoCapture 클래스..  (0) 2015.09.25
Posted by 구차니
embeded/raspberry pi2015. 9. 28. 12:57

라즈베리 파이 2에는 PWM 2채널이 사용이 가능해서

2채널 Servo와

2채널 USB webcam(v4l)을 통해서 비디오를 받아 서보로 제어하도록 해봄



$ g++ cv.cpp -lopencv_core -lopencv_video -lopencv_highgui -lwiringPi 


$ cat cv.cpp

#include <opencv2/core/core.hpp>

#include <opencv2/highgui/highgui.hpp>

#include <iostream>


#include <wiringPi.h>


#define MIN_POS 30

#define MAX_POS 110


using namespace cv;

using namespace std;


void init_wiringpi()

{

        if(wiringPiSetup() == -1) exit(0);


        pinMode(1, PWM_OUTPUT);

        pwmSetMode(PWM_MODE_MS);

//      pwmSetRange(1024);

//      pwmSetClock(400);


        pinMode(23, PWM_OUTPUT);

        pwmSetMode(PWM_MODE_MS);

        pwmSetRange(1024);

        pwmSetClock(400);


        pwmWrite(1,     MIN_POS + (MAX_POS - MIN_POS) / 2);

        pwmWrite(23,    MIN_POS + (MAX_POS - MIN_POS) / 2);

}


void setPWM_1(int val)

{

        pwmWrite(23, val);

}


void setPWM_2(int val)

{

        pwmWrite(1, val);

}



void on_trackbar_1(int pos, void *ptr)

{

        int val = MIN_POS + pos * (MAX_POS - MIN_POS) / 100;

        setPWM_1(val);


        cout << "pos 1 [" << pos << ":" << val << "]" << endl;

}


void on_trackbar_2(int pos, void *ptr)

{

        int val = MIN_POS + pos * (MAX_POS - MIN_POS) / 100;

        setPWM_2(val);


        cout << "pos 2 [" << pos << ":" << val << "]" << endl;

}


void on_trackbar_3(int pos, void *ptr)

{

        int val = MIN_POS + pos * (MAX_POS - MIN_POS) / 100;

//      setPWM_1(val);

//      setPWM_2(val);


        setTrackbarPos("track 1", "cam 1", pos);

        setTrackbarPos("track 2", "cam 2", pos);


        cout << "pos 3 [" << pos << ":" << val << "]" << endl;

}


int main(int argc, char** argv)

{

        // opencv 2 style

        VideoCapture cap(0);

        int pos[2];


        init_wiringpi();


        if(!cap.isOpened())

        {

                cout << "No camera detected" << endl;

                return -1;

        }

        else

        {

                cout << "In capture ..." << endl;

                cap.set(CV_CAP_PROP_FRAME_WIDTH, 320);

                cap.set(CV_CAP_PROP_FRAME_HEIGHT, 240);

        }


        VideoCapture cap2(1);

        if(!cap2.isOpened())

        {

                cout << "No camera detected" << endl;

                return -1;

        }

        else

        {

                cout << "In capture ..." << endl;

                cap2.set(CV_CAP_PROP_FRAME_WIDTH, 320);

                cap2.set(CV_CAP_PROP_FRAME_HEIGHT, 240);

        }


        namedWindow("cam 1", WINDOW_AUTOSIZE );

        namedWindow("cam 2", WINDOW_AUTOSIZE );

        namedWindow("control", WINDOW_AUTOSIZE );


        createTrackbar("track 1", "cam 1", &pos[0], 100, on_trackbar_1 );

        createTrackbar("track 2", "cam 2", &pos[1], 100, on_trackbar_2 );

        createTrackbar("track 3", "control", &pos[0], 100, on_trackbar_3 );


        setTrackbarPos("track 1", "cam 1", 50);

        setTrackbarPos("track 2", "cam 2", 50);

        setTrackbarPos("track 3", "control", 50);


        for(;;)

        {

                Mat frame;

                if(!cap.read(frame)) break;

                imshow("cam 1", frame);


                if(!cap2.read(frame)) break;

                imshow("cam 2", frame);


                if(waitKey(30) >= 0) break;

        }


        return 0;

} 


이제...

다음 목표는 오른쪽 카메라 중앙을 ROI 로 설정하여

왼쪽의 카메라와 같은 곳을 바라보도록 서보를 제어하는 것!

'embeded > raspberry pi' 카테고리의 다른 글

webiopi - rpi IoT  (2) 2015.10.01
라즈베리 파이 v4l2-ctl 관련  (0) 2015.10.01
라즈베리 파이 PWM 데이터 시트  (0) 2015.09.28
wiring pi PWM / c 코드  (0) 2015.09.28
뻘짓은 하긴 했는데... (카메라 + 서보)*2  (0) 2015.09.24
Posted by 구차니
embeded/raspberry pi2015. 9. 28. 12:56

pwm 클럭은 채널 1/2에 동일하게 들어가는 듯?


데이터 시트 141p

PWM clock source and frequency is controlled in CPRMAN. 


데이터 시트 138p

채널은 2개 이지만 연결 가능한 GPIO는 여러개로 보인다.

 GPIO가 여러개 라고 해도 동시에 활성화 가능한건 2채널이려나?


+

40번 이후 부터는 compute module에서나 쓸수 있을테고

라즈베리 파이 2에서는

좌/우 로 2개씩 총 4개의 핀이지만 2개의 채널이니까 12,13번 핀을 나란히 써주는 것도 무난 할 듯?

 +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+

 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |

 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+

 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |

 |   2 |   8 |   SDA.1 |   IN | 1 |  3 || 4  |   |      | 5V      |     |     |

 |   3 |   9 |   SCL.1 |   IN | 1 |  5 || 6  |   |      | 0v      |     |     |

 |   4 |   7 | GPIO. 7 |   IN | 1 |  7 || 8  | 1 | ALT0 | TxD     | 15  | 14  |

 |     |     |      0v |      |   |  9 || 10 | 1 | ALT0 | RxD     | 16  | 15  |

 |  17 |   0 | GPIO. 0 |   IN | 0 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 18  |

 |  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |

 |  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 23  |

 |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 24  |

 |  10 |  12 |    MOSI |   IN | 0 | 19 || 20 |   |      | 0v      |     |     |

 |   9 |  13 |    MISO |   IN | 0 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 25  |

 |  11 |  14 |    SCLK |   IN | 0 | 23 || 24 | 1 | IN   | CE0     | 10  | 8   |

 |     |     |      0v |      |   | 25 || 26 | 1 | IN   | CE1     | 11  | 7   |

 |   0 |  30 |   SDA.0 |   IN | 1 | 27 || 28 | 1 | IN   | SCL.0   | 31  | 1   |

 |   5 |  21 | GPIO.21 |   IN | 1 | 29 || 30 |   |      | 0v      |     |     |

 |   6 |  22 | GPIO.22 |   IN | 1 | 31 || 32 | 0 | IN   | GPIO.26 | 26  | 12  |

 |  13 |  23 | GPIO.23 |   IN | 0 | 33 || 34 |   |      | 0v      |     |     |

 |  19 |  24 | GPIO.24 |   IN | 0 | 35 || 36 | 0 | IN   | GPIO.27 | 27  | 16  |

 |  26 |  25 | GPIO.25 |   IN | 0 | 37 || 38 | 0 | IN   | GPIO.28 | 28  | 20  |

 |     |     |      0v |      |   | 39 || 40 | 0 | IN   | GPIO.29 | 29  | 21  |

 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+

 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |

 +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+



+


클럭관련해서는 PWM 쪽이 아닌 상위에서 넣어준다.

[링크 : http://www.farnell.com/datasheets/1521578.pdf]



---


wiring pi 상으로는 ABC 정렬도 아닌거 같고..

그냥 초기화 해야 하는 순서대로

Mode / Range / Clock 순인것 같다.

PWM Control


PWM can not be controlled when running in Sys mode.

  • pwmSetMode (int mode) ;

The PWM generator can run in 2 modes – “balanced” and “mark:space”. The mark:space mode is traditional, however the default mode in the Pi is “balanced”. You can switch modes by supplying the parameter: PWM_MODE_BAL or PWM_MODE_MS.

  • pwmSetRange (unsigned int range) ;

This sets the range register in the PWM generator. The default is 1024.

  • pwmSetClock (int divisor) ;

This sets the divisor for the PWM clock.

To understand more about the PWM system, you’ll need to read the Broadcom ARM peripherals manual.

[링크 : https://projects.drogon.net/raspberry-pi/wiringpi/functions/] 


Posted by 구차니
embeded/raspberry pi2015. 9. 28. 08:29


void pinMode (int pin, int mode) ;

This sets the mode of a pin to either INPUT, OUTPUT, or PWM_OUTPUT. Note that only wiringPi pin 1 (BCM_GPIO 18) supports PWM output.


void pwmWrite (int pin, int value) ;

Writes the value to the PWM register for the given pin. The value must be between 0 and 1024. (Again, note that only pin 1 (BCM_GPIO 18) supports PWM)


pwmSetMode (int mode) ;

The PWM generator can run in 2 modes – “balanced” and “mark:space”. The mark:space mode is traditional, however the default mode in the Pi is “balanced”. You can switch modes by supplying the parameter: PWM_MODE_BAL or PWM_MODE_MS.


pwmSetRange (unsigned int range) ;

This sets the range register in the PWM generator. The default is 1024.


pwmSetClock (int divisor) ;

This sets the divisor for the PWM clock.


[링크 : https://projects.drogon.net/raspberry-pi/wiringpi/functions/]


LED PWM 예제 - c언어 / wiring pi

[링크 : https://learn.sparkfun.com/tutorials/raspberry-gpio/c-wiringpi-example]


python / pwm 2 ch 예제

[링크 : http://electronut.in/controlling-two-servos-with-hardware-pwm-on-the-raspberry-pi-model-a/]

Posted by 구차니