Programming/openMP2015. 9. 30. 15:16

openCV 2.4.6 부터 Use openMP 옵션이 추가된 기분?

[링크 : https://iamsrijon.wordpress.com/./how-to-compile-opencv-to-utilize-multiple-core-processor-in-linux/]

[링크 : http://answers.opencv.org/question/20955/enabling-openmp-while-building-opencv-libraries/]


결국은. 또 다시 크로스 컴파일이거나...

빌드의 시간인가!?!??



물론.. opencv2가 아닌 opencv에서도 수작업으로 병렬화는 가능한듯

[링크 : https://huseyincakir.wordpress.com/2009/11/05/using-openmp-with-opencv/]


openCV2 2.4.0 에서도 무언가 테스트는 했는데 코드가 없어서 아쉽네..

[링크 : http://museguy.tistory.com/16]



2.4.6

switched all the remaining parallel loops from TBB-only tbb::parallel_for() to universal cv::parallel_for_() with many possible backends (MS Concurrency, Apple's GDC, OpenMP, Intel TBB etc.)


2.4.3

Added universal parallel_for implementation using various backends: TBB (cross-platform: http://threadingbuildingblocks.org), OpenMP (cross-platform: http://en.wikipedia.org/wiki/OpenMP), Grand Central Dispatch (iOS/MacOSX: http://en.wikipedia.org/wiki/Grand_Central_Dispatch), Concurrency (Visual Studio 2010 or later: http://msdn.microsoft.com/en-us/library/dd492418.aspx), C= (http://www.hoopoesnest.com/cstripes/cstripes-details.htm). Many exiting parallel OpenCV algorithms have been converted to the new primitive. Therefore, you can enjoy performance improvements even without having to install TBB and ship it with OpenCV-based applications.


[링크 : http://code.opencv.org/projects/opencv/wiki/ChangeLog]

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

openmp 관련 정리글(win32)  (0) 2015.10.08
openmp 테스트 on rpi  (0) 2015.10.06
openMP affinity 관련..  (0) 2015.07.23
openMP parallel for private  (4) 2013.12.12
openMP private copyin copyprivate firstprivate lastprivate  (0) 2013.11.28
Posted by 구차니
Programming/C Win32 MFC2015. 9. 30. 15:00

그냥 콘솔창에서도 사용이 가능해 보이니 돌려볼까..


[링크 : http://linuxpoison.blogspot.kr/2010/06/cppcheck-tool-for-static-c-c-code.html]

[링크 : http://cppcheck.sourceforge.net/]

[링크 : http://cppcheck.sourceforge.net/demo/]


우분투에서는 cppcheck 라는 이름으로 있군..

[링크 : http://packages.ubuntu.com/precise/devel/cppcheck]


$ sudo apt-get install cppcheck

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following extra packages will be installed:

  libtinyxml2.6.2

The following NEW packages will be installed:

  cppcheck libtinyxml2.6.2

0 upgraded, 2 newly installed, 0 to remove and 81 not upgraded.

Need to get 604 kB of archives.

After this operation, 1,466 kB of additional disk space will be used.

Do you want to continue [Y/n]?

Get:1 http://archive.ubuntu.com/ubuntu/ precise/universe libtinyxml2.6.2 amd64 2                                      .6.2-1build1 [35.3 kB]

Get:2 http://archive.ubuntu.com/ubuntu/ precise/universe cppcheck amd64 1.52-1 [                                      569 kB]

Fetched 604 kB in 2s (225 kB/s)

Selecting previously unselected package libtinyxml2.6.2.

(Reading database ... 213921 files and directories currently installed.)

Unpacking libtinyxml2.6.2 (from .../libtinyxml2.6.2_2.6.2-1build1_amd64.deb) ...

Selecting previously unselected package cppcheck.

Unpacking cppcheck (from .../cppcheck_1.52-1_amd64.deb) ...

Processing triggers for man-db ...

Setting up libtinyxml2.6.2 (2.6.2-1build1) ...

Setting up cppcheck (1.52-1) ...

Processing triggers for libc-bin ...

ldconfig deferred processing now taking place 


Example usage:

  # Recursively check the current folder. Print the progress on the screen and

    write errors to a file:

    cppcheck . 2> err.txt

  # Recursively check ../myproject/ and don't print progress:

    cppcheck --quiet ../myproject/

  # Check only files one.cpp and two.cpp and give all information there is:

    cppcheck -v -s one.cpp two.cpp

  # Check f.cpp and search include files from inc1/ and inc2/:

    cppcheck -I inc1/ -I inc2/ f.cpp


For more information:

    http://cppcheck.sf.net/manual.pdf


-s를 써보라고 예제가 써있어서 해봤더니 style 체크.. 하지만 deprecated라 경고가 뜬다.

    -s, --style          Deprecated, please use '--enable=style' instead

    -v, --verbose        Output more detailed error information.
    -j <jobs>            Start [jobs] threads to do the checking simultaneously.

의외로 경고 뿜뿜을 안해서 실망.. 복잡한 코드를 돌려봐야 하려나?

암튼. make 처럼 -j 옵션을 지원한다.

'Programming > C Win32 MFC' 카테고리의 다른 글

"\n" 의 cpu 점유율?  (0) 2015.10.12
rand()와 RAND_MAX  (0) 2015.10.05
void형 포인터 ++  (0) 2015.07.14
가변인자를 다시 넘겨주기  (2) 2015.07.07
printf 가변인자의 비밀?  (0) 2015.06.18
Posted by 구차니
Programming/openCV2015. 9. 30. 13:42

3.0.0... 세상은 날 기다려 주지 않는구만 -_-


[링크 : http://opencv.org/downloads.html]


라즈베리 파이에서 사용중인 2.4.1은.. 2012년 6월 버전인가? ㄷㄷㄷ

[링크 : https://github.com/Itseez/opencv/tree/2.4.1]



June, 2015

These are changes since 3.0 rc1.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Over 200 bugs reported at http://code.opencv.org/projects/opencv/issues have been resolved/closed. It includes many fixes in docs, build scripts, python wrappers, core, imgproc, photo, features2d, objdetect, contrib modules, as well as some performance improvements etc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Added pthreads-based backend for cv::parallel_for_. It means that all the parallel processing should be available out-of-the-box on any POSIX-compatible OS, including QNX and such. You are welcome to try it out.


Improved compatibility with OpenCV 2.4:

2.4.11 now includes “opencv2/core.hpp” and other such headers in addition to standard “opencv2/core/core.hpp”.

smart pointers (Ptr<>) can now be created in both 2.4 and 3.0 style (new ClassName(params) vs makePtr(params))

trained and stored stat models from opencv_ml 2.4 can now be loaded and used by opencv_ml 3.0 as-is.

the 2.4=>3.0 transition guide has been sketched: http://docs.opencv.org/master/db/dfa/tutorial_transition_guide.html


[링크 : https://github.com/Itseez/opencv/wiki/ChangeLog]


2.4 -> 3.0 가이드

[링크 : http://docs.opencv.org/master/db/dfa/tutorial_transition_guide.html]

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

opencv neon 최적화  (0) 2015.10.01
openCV 템플릿 매칭 예제 실행  (0) 2015.10.01
opencv 템플릿 매칭 관련  (0) 2015.09.28
openCV 에피폴라 기하 관련 내용  (0) 2015.09.28
opencv highgui trackbar  (0) 2015.09.27
Posted by 구차니

타임라인에 대해서 쭈욱 나오는데 귀찮으니 패스~


종족을 나눠서 선택하는게 아니라

미션별로 종족을 골라서 진행 할 수 있네? 오홍?


다음편이라 그런지 확실히 미션 설명등에서

좀더 자유로워진 카메라 앵글을 통해 전장을 보여준다.


종족 선택.. 가장 왼쪽부터 끝내자 ㅋㅋ


아쉬운건.. 전편에는 미션목록이 쭈욱 보였는데

우측 상단에 하나하나 봐야 한다는 정도? 대신 클릭하면 목표지점이 보인다.


시작부터 맵이 크네 ㄷㄷ


자원 재생기 달았더니 커졌.... ㄷㄷㄷ


첫판부터 실험급 무기를 만들수 있네 ㅋㅋㅋ



아오 저 콜로서스 -_-



바글바글..

한번에 보내지 꼭 4마리씩 보내서 우리편 킬수를 올려주는 좋은(?)  AEON


방어막 이펙트가 더 정교해진건가?


ㄷㄷㄷ 콜러서스 2마리 ㄷㄷㄷ


적 대장인가? 드럽게 크고 세다 ㄷㄷ


아무튼 귀차니즘(!) 으로 거점방어 5개 곡사포 5개 에 T3 실드 해놓은거에 녹아내렸...


음.. 교환비가 안나와서 아쉽네


Posted by 구차니
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 구차니
Programming/openCV2015. 9. 27. 21:00

슬라이더라고 해야하려나?

그거 추가하는 내용


그나저나.. 2.4.11.0 문서인데 왜 cpp가 아니라 c로 된게 있지 -ㅁ-?


[링크 : http://docs.opencv.org/modules/highgui/doc/user_interface.html]

[링크 : http://docs.opencv.org/doc/tutorials/highgui/trackbar/trackbar.html]

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

opencv 템플릿 매칭 관련  (0) 2015.09.28
openCV 에피폴라 기하 관련 내용  (0) 2015.09.28
opencv2 마우스 이벤트 / 클릭 위치  (0) 2015.09.25
opencv2.. VideoCapture 클래스..  (0) 2015.09.25
openCV Mat Class  (0) 2014.07.04
Posted by 구차니