Home | History | Annotate | Download | only in src

Lines Matching full:capture

99 static void icvYUY2toBGR( CvCaptureAVI_XINE * capture )
101 uint8_t * v = capture->xine_frame.data;
103 for ( int y = 0; y < capture->yuv_frame->height; y++ )
105 offset = y * capture->yuv_frame->widthStep;
107 for ( int x = 0; x < capture->yuv_frame->width; x++, offset += 3 )
109 capture->yuv_frame->imageData[ offset + 1 ] = v[ 3 ];
110 capture->yuv_frame->imageData[ offset + 2 ] = v[ 1 ];
113 capture->yuv_frame->imageData[ offset ] = v[ 2 ];
118 capture->yuv_frame->imageData[ offset ] = v[ 0 ];
124 cvCvtColor( capture->yuv_frame, capture->bgr_frame, CV_YCrCb2BGR );
129 static void icvYV12toBGR( CvCaptureAVI_XINE * capture )
131 IplImage * yuv = capture->yuv_frame;
132 int w_Y = capture->size.width;
133 int h_Y = capture->size.height;
142 uint8_t * addr_Y = capture->xine_frame.data;
175 cvCvtColor( capture->yuv_frame, capture->bgr_frame, CV_YCrCb2BGR );
178 static void icvCloseAVI_XINE( CvCaptureAVI_XINE* capture )
180 xine_free_video_frame( capture->vo_port, &capture->xine_frame );
182 if ( capture->yuv_frame ) cvReleaseImage( &capture->yuv_frame );
183 if ( capture->bgr_frame ) cvReleaseImage( &capture->bgr_frame );
185 xine_close( capture->stream );
186 // xine_dispose( capture->stream );
188 if ( capture->vo_port ) xine_close_video_driver( capture->xine, capture->vo_port );
190 xine_exit( capture->xine );
195 * CHECKS IF THE STREAM IN * capture IS SEEKABLE.
197 static void icvCheckSeekAVI_XINE( CvCaptureAVI_XINE * capture )
199 OPENCV_ASSERT ( capture, "icvCheckSeekAVI_XINE( CvCaptureAVI_XINE* )", "illegal capture");
200 OPENCV_ASSERT ( capture->stream,
201 "icvCheckSeekAVI_XINE( CvCaptureAVI_XINE* )", "illegal capture->stream");
202 OPENCV_ASSERT ( capture->vo_port,
203 "icvCheckSeekAVI_XINE( CvCaptureAVI_XINE* )", "illegal capture->vo_port");
212 xine_play( capture->stream, 0, 300 ); /* 300msec */
214 xine_get_next_video_frame( capture->vo_port, &tmp );
216 capture->seekable = ( tmp.frame_number != 0 );
218 xine_play( capture->stream, 0, 0 );
220 xine_free_video_frame( capture->vo_port, &tmp );
223 if ( capture->seekable )
233 static int icvOpenAVI_XINE( CvCaptureAVI_XINE* capture, const char* filename )
241 capture->xine = xine_new();
244 xine_config_load( capture->xine, configfile );
245 xine_init( capture->xine );
247 xine_engine_set_param( capture->xine, 0, 0 );
248 capture->vo_port = xine_new_framegrab_video_port( capture->xine );
249 if ( capture->vo_port == NULL )
255 capture->stream = xine_stream_new( capture->xine, NULL, capture->vo_port );
257 if ( !xine_open( capture->stream, filename ) )
263 xine_play( capture->stream, 0, 0 );
267 capture->frame_number = 0;
269 if ( !xine_get_next_video_frame( capture->vo_port, &capture->xine_frame ) )
277 capture->size = cvSize( capture->xine_frame.width, capture->xine_frame.height );
278 capture->yuv_frame = cvCreateImage( capture->size, IPL_DEPTH_8U, 3 );
279 capture->bgr_frame = cvCreateImage( capture->size, IPL_DEPTH_8U, 3 );
281 xine_free_video_frame( capture->vo_port, &capture->xine_frame );
282 capture->xine_frame.data[ 0 ] = 0;
284 icvCheckSeekAVI_XINE( capture );
286 capture->frame_duration = xine_get_stream_info( capture->stream, XINE_STREAM_INFO_FRAME_DURATION ) / 90.;
287 capture->frame_rate = 1000 / capture->frame_duration;
290 fprintf( stderr, "(DEBUG) frame_duration = %f, framerate = %f\n", capture->frame_duration, capture->frame_rate );
293 OPENCV_ASSERT ( capture->yuv_frame,
296 OPENCV_ASSERT ( capture->bgr_frame,
306 static int icvGrabFrameAVI_XINE( CvCaptureAVI_XINE* capture )
312 OPENCV_ASSERT ( capture,
313 "icvGrabFrameAVI_XINE( CvCaptureAVI_XINE * )", "illegal capture");
314 OPENCV_ASSERT ( capture->vo_port,
315 "icvGrabFrameAVI_XINE( CvCaptureAVI_XINE * )", "illegal capture->vo_port");
317 int res = xine_get_next_video_frame( capture->vo_port, &capture->xine_frame );
320 if ( res ) capture->frame_number++;
329 static const IplImage* icvRetrieveFrameAVI_XINE( CvCaptureAVI_XINE* capture, int )
335 OPENCV_ASSERT ( capture,
336 "icvRetrieveFrameAVI_XINE( CvCaptureAVI_XINE * )", "illegal capture");
337 OPENCV_ASSERT ( capture->stream,
338 "icvRetrieveFrameAVI_XINE( CvCaptureAVI_XINE * )", "illegal capture->stream");
339 OPENCV_ASSERT ( capture->vo_port,
340 "icvRetrieveFrameAVI_XINE( CvCaptureAVI_XINE * )", "illegal capture->vo_port");
344 if ( capture->xine_frame.data == 0 )
346 res = icvGrabFrameAVI_XINE( capture );
355 switch ( capture->xine_frame.colorspace )
357 case XINE_IMGFMT_YV12: icvYV12toBGR( capture );
363 case XINE_IMGFMT_YUY2: icvYUY2toBGR( capture );
377 /* always release last xine_frame, not needed anymore, but store its frame_number in *capture ! */
378 xine_free_video_frame( capture->vo_port, &capture->xine_frame );
379 capture->xine_frame.data = 0;
384 return capture->bgr_frame;
399 static int icvOldSeekFrameAVI_XINE( CvCaptureAVI_XINE* capture, int f )
405 OPENCV_ASSERT ( capture,
406 "icvRetricvOldSeekFrameAVI_XINE( CvCaptureAVI_XINE *, int )", "illegal capture");
407 OPENCV_ASSERT ( capture->stream,
408 "icvOldSeekFrameAVI_XINE( CvCaptureAVI_XINE *, int )", "illegal capture->stream");
409 OPENCV_ASSERT ( capture->vo_port,
410 "icvOldSeekFrameAVI_XINE( CvCaptureAVI_XINE *, int )", "illegal capture->vo_port");
413 // we need a valid capture context and it's stream to seek through
414 // if ( !capture || !capture->stream ) return 0;
417 if ( f == capture->frame_number )
426 else if ( f > capture->frame_number )
428 for ( ;capture->frame_number < f;capture->frame_number++ )
430 if ( !xine_get_next_video_frame( capture->vo_port, &capture->xine_frame ) )
432 capture->frame_number--;
437 xine_free_video_frame( capture->vo_port, &capture->xine_frame );
442 else // f < capture->frame_number
445 xine_play( capture->stream, 0, 0 );
447 for ( capture->frame_number = 0; capture->frame_number < f; capture->frame_number++ )
449 if ( !xine_get_next_video_frame( capture->vo_port, &capture->xine_frame ) )
451 capture->frame_number--;
456 xine_free_video_frame( capture->vo_port, &capture->xine_frame );
464 return ( f == capture->frame_number ) ? 1 : 0;
468 static int icvSeekFrameAVI_XINE( CvCaptureAVI_XINE* capture, int f )
474 OPENCV_ASSERT ( capture,
475 "icvSeekFrameAVI_XINE( CvCaptureAVI_XINE *, int )", "illegal capture");
476 OPENCV_ASSERT ( capture->stream,
477 "icvSeekFrameAVI_XINE( CvCaptureAVI_XINE *, int )", "illegal capture->stream");
478 OPENCV_ASSERT ( capture->vo_port,
479 "icvSeekFrameAVI_XINE( CvCaptureAVI_XINE *, int )", "illegal capture->vo_port");
482 // we need a valid capture context and it's stream to seek through
483 // if ( !capture || !capture->stream ) return 0;
485 if ( capture->seekable )
489 int new_time = ( int ) ( ( f + 1 ) * ( float ) capture->frame_duration );
494 if ( xine_play( capture->stream, 0, new_time ) )
500 capture
517 return icvOldSeekFrameAVI_XINE( capture, f );
522 static int icvSeekTimeAVI_XINE( CvCaptureAVI_XINE* capture, int t )
528 OPENCV_ASSERT ( capture,
529 "icvSeekTimeAVI_XINE( CvCaptureAVI_XINE *, int )", "illegal capture");
530 OPENCV_ASSERT ( capture->stream,
531 "icvSeekTimeAVI_XINE( CvCaptureAVI_XINE *, int )", "illegal capture->stream");
532 OPENCV_ASSERT ( capture->vo_port,
533 "icvSeekTimeAVI_XINE( CvCaptureAVI_XINE *, int )", "illegal capture->vo_port");
540 // we need a valid capture context and it's stream to seek through
541 // if ( !capture || !capture->stream ) return 0;
543 if ( capture->seekable )
546 if ( xine_play( capture->stream, 0, t ) )
548 capture->frame_number = ( int ) ( ( float ) t * capture->frame_rate / 1000 );
564 int new_frame = ( int ) ( ( float ) t * capture->frame_rate / 1000 );
568 return icvOldSeekFrameAVI_XINE( capture, new_frame );
573 static int icvSeekRatioAVI_XINE( CvCaptureAVI_XINE* capture, double ratio )
579 OPENCV_ASSERT ( capture,
580 "icvSeekRatioAVI_XINE( CvCaptureAVI_XINE *, double )", "illegal capture");
581 OPENCV_ASSERT ( capture->stream,
582 "icvSeekRatioAVI_XINE( CvCaptureAVI_XINE *, double )", "illegal capture->stream");
583 OPENCV_ASSERT ( capture->vo_port,
584 "icvSeekRatioAVI_XINE( CvCaptureAVI_XINE *, double )", "illegal capture->vo_port");
587 // we need a valid capture context and it's stream to seek through
588 // if ( !capture || !capture->stream ) return 0;
593 if ( capture->seekable )
597 xine_get_pos_length( capture->stream, &pos_l, &pos_t, &length );
601 if ( xine_play( capture->stream, (int)(ratio*(float)length), 0 ) )
603 capture->frame_number = ( int ) ( ratio*length / capture->frame_duration );
631 static double icvGetPropertyAVI_XINE( CvCaptureAVI_XINE* capture, int property_id )
637 OPENCV_ASSERT ( capture,
638 "icvGetPropertyAVI_XINE( CvCaptureAVI_XINE *, int )", "illegal capture");
639 OPENCV_ASSERT ( capture->stream,
640 "icvGetPropertyAVI_XINE( CvCaptureAVI_XINE *, int )", "illegal capture->stream");
641 OPENCV_ASSERT ( capture->vo_port,
642 "icvGetPropertyAVI_XINE( CvCaptureAVI_XINE *, int )", "illegal capture->vo_port");
643 OPENCV_ASSERT ( capture->xine,
644 "icvGetPropertyAVI_XINE( CvCaptureAVI_XINE *, int )", "illegal capture->xine");
645 OPENCV_ASSERT ( capture->bgr_frame,
646 "icvGetPropertyAVI_XINE( CvCaptureAVI_XINE *, int )", "illegal capture->bgr_frame");
649 // we need a valid capture context and it's stream to seek through
650 // if ( !capture || !capture->stream || !capture->bgr_frame || !capture->xine || !capture->vo_port ) return 0
653 xine_get_pos_length( capture->stream, &pos_l, &pos_t, &length );
660 if ( !capture->seekable )
669 /// we insist the capture->frame_number to be remain updated !!!!
670 return capture->frame_number;
675 if ( !capture->seekable )
686 return capture->size.width;
690 return capture->size.height;
694 if ( !capture->seekable )
699 return capture->frame_rate;
703 return ( double ) xine_get_stream_info( capture->stream, XINE_STREAM_INFO_VIDEO_FOURCC );
714 static int icvSetPropertyAVI_XINE( CvCaptureAVI_XINE* capture,
721 OPENCV_ASSERT ( capture,
722 "icvSetPropertyAVI_XINE( CvCaptureAVI_XINE *, int, double )", "illegal capture");
723 OPENCV_ASSERT ( capture->stream,
724 "icvGetPropericvSetPropertyAVI_XINE( CvCaptureAVI_XINE *, int )", "illegal capture->stream");
725 OPENCV_ASSERT ( capture->vo_port,
726 "icvSetPropertyAVI_XINE( CvCaptureAVI_XINE *, int, double )", "illegal capture->vo_port");
729 // we need a valid capture context and it's stream to seek through
730 // if ( !capture || !capture->stream || !capture->bgr_frame || !capture->xine || !capture->vo_port ) return 0
740 return icvSeekTimeAVI_XINE( capture, ( int ) value );
744 return icvSeekFrameAVI_XINE( capture, ( int ) value );
749 return icvSeekRatioAVI_XINE( capture, value );
763 // construct capture struct
764 CvCaptureAVI_XINE * capture = ( CvCaptureAVI_XINE* ) cvAlloc ( sizeof ( CvCaptureAVI_XINE ) );
765 memset( capture, 0, sizeof ( CvCaptureAVI_XINE ) );
768 if ( !icvOpenAVI_XINE( capture, filename ) )
771 OPENCV_ASSERT ( capture,
772 "cvCaptureFromFile_XINE( const char * )", "couldn't create capture");
774 return capture;
836 CvCaptureAVI_XINE_CPP* capture = new CvCaptureAVI_XINE_CPP;
838 if( capture->open(filename))
839 return capture;
841 delete capture;