되거나
안되거나
OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /usr/src/packages/BUILD/opencv-2.4.1+dfsg/modules/core/src/array.cpp, line 2482 terminate called after throwing an instance of 'cv::Exception' what(): /usr/src/packages/BUILD/opencv-2.4.1+dfsg/modules/core/src/array.cpp:2482: error: (-206) Unrecognized or unsupported array type in function cvGetMat |
소스는 간단한데..
구동이 될때도 있고 안될때도 있고.. 머지?
+2015.11.10
생각해보니 mutex 변수는 별도 프로세스에서 공유가 안되니..
실질적으로는 lock이 안되는 걸지도?
$ cat cvmp.cpp #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <iostream> #include <mutex> #include <omp.h>
#define WIN_CAPT "capture" #define WIN_PROC "process" #define WIN_DISP "display"
using namespace cv; using namespace std;
Mat vcap; Mat vproc; Mat vdisp;
VideoCapture cap;
std::mutex mproc; std::mutex mdisp;
void init_wiringpi() { }
void init_video() { cap.open(0); if(cap.isOpened()) { cap.set(CV_CAP_PROP_FRAME_WIDTH, 320); cap.set(CV_CAP_PROP_FRAME_HEIGHT, 240); } }
void video_capture() { mproc.lock(); cap.read(vcap); imshow(WIN_CAPT, vcap); mproc.unlock(); }
void video_process() { mproc.lock(); vcap.copyTo(vproc); mproc.unlock(); imshow(WIN_PROC, vproc); }
void video_display() { mdisp.lock(); vproc.copyTo(vdisp); mdisp.unlock(); imshow(WIN_DISP, vdisp); }
int main(int argc, char **argv) { init_wiringpi(); init_video();
namedWindow(WIN_CAPT, WINDOW_AUTOSIZE ); namedWindow(WIN_PROC, WINDOW_AUTOSIZE );
for(;;) { #pragma omp parallel sections { #pragma omp section { video_capture(); } #pragma omp section { video_process(); } }
if(waitKey(30) >= 0) break; }
return 0; } |
아무튼.. 멀티프로세스로 돌아가는 가는데
$ pstree
├─sshd─┬─sshd───sshd───bash───cvmp.o───3*[{cvmp.o}]
│ └─sshd───sshd───bash───pstree
htop 상으로는 그닥.. 분리되는 기분이 안든다고 해야하나...?
top으로 보면 조금 분리되서 cpu를 잡아먹는거 같긴하다.
$ top
top - 11:42:15 up 2:32, 2 users, load average: 0.62, 0.24, 0.16
Tasks: 111 total, 2 running, 109 sleeping, 0 stopped, 0 zombie
%Cpu0 : 45.3 us, 4.3 sy, 0.0 ni, 47.0 id, 0.0 wa, 0.0 hi, 3.3 si, 0.0 st
%Cpu1 : 11.0 us, 0.3 sy, 0.0 ni, 88.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
%Cpu2 : 33.1 us, 1.4 sy, 0.0 ni, 65.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
%Cpu3 : 4.0 us, 0.0 sy, 0.0 ni, 95.7 id, 0.0 wa, 0.0 hi, 0.3 si, 0.0 st
KiB Mem: 883160 total, 182500 used, 700660 free, 19316 buffers
KiB Swap: 102396 total, 0 used, 102396 free, 102840 cached
그나저나 mutex가 제대로 되는진 어떻게 검증하지? ㅠㅠ
+
[링크 : http://what-the-pixel.blogspot.kr/2013/05/getting-started-with-openmp.html]