공부해요/OpenCV

[ openCV 제대로 배우기 ] ex2-3.exe - 간단한 사용자 인터페이스 추가

예쁜꽃이피었으면 2014. 7. 28. 09:27


# include <opencv\cv.h> 

# include <opencv\highgui.h> 


int g_slider_position = 0;

CvCapture* g_capture = NULL;


void onTrackbarSlide(int pos){

cvSetCaptureProperty(

g_capture,

CV_CAP_PROP_POS_FRAMES,

pos

);

}


int main(int arc , char** argv){

cvNamedWindow("Example3",CV_WINDOW_AUTOSIZE);

//g_capture = cvCreateFileCapture(argv[1]); //argv[1]에 동영상 경로

g_capture = cvCreateFileCapture("C:/Users/hyunok/Desktop/videoplayback");

int frames = (int) cvGetCaptureProperty(

g_capture,

CV_CAP_PROP_FRAME_COUNT

);

if(frames != 0 ){

cvCreateTrackbar(

"Position", // 슬라이더바에 표시되는 이름

"Example3", //윈도우 이름

&g_slider_position, //슬라이더 위치

frames,

onTrackbarSlide

);

}

IplImage* frame;

char c;

while(1){

frame = cvQueryFrame(g_capture);

if( !frame) break;

cvShowImage("Example3",frame);


c = cvWaitKey(33);

if(c==27) break;

}

cvReleaseCapture(&g_capture);

cvDestroyWindow("Example3");


return(0);

}



반응형