Professional Documents
Culture Documents
Xuan Mo
iPAL Group Meeting
Outline
Reading video Writing video Edge Detection Demo: Laplacian edge detection
2/11/2011
2/11/2011
Get capture device properties: cvQueryF rame(capture); this call is necessary to get correct capture properties cvGetCaptureP roperty(capture, property id, value); property id: CV CAP P ROP F RAM E HEIGHT CV CAP P ROP F RAM E W IDT H CV CAP P ROP F P S CV CAP P ROP F RAM E COU N T Frame count does not seem to be working properly.
2/11/2011
Function is the same: cvGetCaptureP roperty(capture, property id, value); property id: CV CAP P ROP P OS M SEC CV CAP P ROP P OS F RAM ES CV CAP P ROP P OS AV I RAT IO(0 1) and so on...
2/11/2011
Set capture device properties: cvSetCaptureP roperty(capture, property id, value); sets the specied property of camera or AVI. property id: The same as getting frame information Example: cvSetCaptureP roperty (capture, CV CAP P ROP P OS AV I RAT IO, 0.9); start capturing from a relative position of 0.9 of a video le
2/11/2011
Write/save video
First initializing a video writer: CvV ideoW ritercvCreateV ideoW riter (f ilename, f ourcc, f ps, f rame size, is color = 1) fourcc: four-Character Codes CV F OU RCC( P , I , M , 1 ) : M P EG 1 CV F OU RCC( M , J , P , G ) : motion jpeg CV F OU RCC( M , P , 4 , 2 ) : M P EG 4.2 CV F OU RCC( D , I , V , 3 ) : M P EG 4.3 CV F OU RCC( D , I , V , X ) : M P EG 4 = M P EG 1 CV F OU RCC( U , 2 , 6 , 3 ) : H263 CV F OU RCC( I , 2 , 6 , 3 ) : H263I CV F OU RCC( F , L , V , 1 ) : F LV 1 Example: CvV ideoW riterwriter = 0; writer = cvCreateV ideoW riter(. . . )
2/11/2011 iPAL Group Meeting 7
Write/save video
Then writing the video le: add the frame to the le cvW riteF rame(writer, img); Example: IplImage img = 0; intnF rames = 50; f or(i = 0; i < nF rames; i + +){ cvGrabF rame(capture); img = cvRetrieveF rame(capture); cvW riteF rame(writer, img); } view the captured frames during capture cvShowImage(mainW in, img); key = cvW aitKey(20); wait 20 ms wait 20 ms in order to display properly
2/11/2011
Edge detection
search-based
... ...
1 2
Computing a measure of edge strength, usually a rst-order derivative expression such as the gradient magnitude. Searching for local directional maxima of the gradient magnitude using a computed estimate of the local orientation of the edge, usually the gradient direction.
zero-crossing based search for zero crossings in a second-order derivative expression computed from the image in order to nd edges, usually the zero-crossings of the Laplacian or the zero-crossings of a non-linear dierential expression.
2/11/2011
2/11/2011
10
...
1
. . . .
Function: cvSmooth
Function: cvSplit
...
6
2/11/2011
11