@@ -287,6 +287,8 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
287
287
}
288
288
289
289
int depth = 3 ;
290
+ bool height_extend = false ;
291
+
290
292
#if GST_VERSION_MAJOR > 0
291
293
depth = 0 ;
292
294
const gchar* name = gst_structure_get_name (structure);
@@ -295,9 +297,16 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
295
297
if (!name)
296
298
return 0 ;
297
299
298
- // we support 3 types of data:
300
+ // we support 11 types of data:
299
301
// video/x-raw, format=BGR -> 8bit, 3 channels
300
302
// video/x-raw, format=GRAY8 -> 8bit, 1 channel
303
+ // video/x-raw, format=UYVY -> 8bit, 2 channel
304
+ // video/x-raw, format=YUY2 -> 8bit, 2 channel
305
+ // video/x-raw, format=YVYU -> 8bit, 2 channel
306
+ // video/x-raw, format=NV12 -> 8bit, 1 channel (height is 1.5x larger than true height)
307
+ // video/x-raw, format=NV21 -> 8bit, 1 channel (height is 1.5x larger than true height)
308
+ // video/x-raw, format=YV12 -> 8bit, 1 channel (height is 1.5x larger than true height)
309
+ // video/x-raw, format=I420 -> 8bit, 1 channel (height is 1.5x larger than true height)
301
310
// video/x-bayer -> 8bit, 1 channel
302
311
// image/jpeg -> 8bit, mjpeg: buffer_size x 1 x 1
303
312
// bayer data is never decoded, the user is responsible for that
@@ -311,6 +320,13 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
311
320
if (strcasecmp (format, " BGR" ) == 0 ) {
312
321
depth = 3 ;
313
322
}
323
+ else if ( (strcasecmp (format, " UYVY" ) == 0 ) || (strcasecmp (format, " YUY2" ) == 0 ) || (strcasecmp (format, " YVYU" ) == 0 ) ){
324
+ depth = 2 ;
325
+ }
326
+ else if ( (strcasecmp (format, " NV12" ) == 0 ) || (strcasecmp (format, " NV21" ) == 0 ) || (strcasecmp (format, " YV12" ) == 0 ) || (strcasecmp (format, " I420" ) == 0 ) ){
327
+ depth = 1 ;
328
+ height_extend = true ;
329
+ }
314
330
else if (strcasecmp (format, " GRAY8" ) == 0 ){
315
331
depth = 1 ;
316
332
}
@@ -324,7 +340,11 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
324
340
}
325
341
#endif
326
342
if (depth > 0 ) {
327
- frame = cvCreateImageHeader (cvSize (width, height), IPL_DEPTH_8U, depth);
343
+ if (height_extend){
344
+ frame = cvCreateImageHeader (cvSize (width, height*3 /2 ), IPL_DEPTH_8U, depth);
345
+ }else {
346
+ frame = cvCreateImageHeader (cvSize (width, height), IPL_DEPTH_8U, depth);
347
+ }
328
348
} else {
329
349
gst_caps_unref (buffer_caps);
330
350
return 0 ;
@@ -810,8 +830,20 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
810
830
" blue_mask" , G_TYPE_INT, 0xFF0000 ,
811
831
NULL );
812
832
#else
813
- // support 1 and 3 channel 8 bit data, as well as bayer (also 1 channel, 8bit)
833
+
814
834
caps = gst_caps_from_string (" video/x-raw, format=(string){BGR, GRAY8}; video/x-bayer,format=(string){rggb,bggr,grbg,gbrg}; image/jpeg" );
835
+
836
+ if (manualpipeline){
837
+ GstPad* sink_pad = gst_element_get_static_pad (sink, " sink" );
838
+ GstCaps* peer_caps = gst_pad_peer_query_caps (sink_pad,NULL );
839
+ if (!gst_caps_can_intersect (caps, peer_caps)) {
840
+ gst_caps_unref (caps);
841
+ caps = gst_caps_from_string (" video/x-raw, format=(string){UYVY,YUY2,YVYU,NV12,NV21,YV12,I420}" );
842
+ }
843
+ gst_object_unref (sink_pad);
844
+ gst_caps_unref (peer_caps);
845
+ }
846
+
815
847
#endif
816
848
gst_app_sink_set_caps (GST_APP_SINK (sink), caps);
817
849
gst_caps_unref (caps);
0 commit comments