@@ -178,6 +178,8 @@ class CvCapture_GStreamer : public CvCapture
178
178
bool isPosFramesSupported;
179
179
bool isPosFramesEmulated;
180
180
gint64 emulatedFrameNumber;
181
+
182
+ bool isOutputByteBuffer;
181
183
};
182
184
183
185
/* !
@@ -205,6 +207,8 @@ void CvCapture_GStreamer::init()
205
207
isPosFramesSupported = false ;
206
208
isPosFramesEmulated = false ;
207
209
emulatedFrameNumber = -1 ;
210
+
211
+ isOutputByteBuffer = false ;
208
212
}
209
213
210
214
/* !
@@ -357,6 +361,7 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
357
361
} else if (strcasecmp (name, " image/jpeg" ) == 0 ) {
358
362
depth = 1 ;
359
363
// the correct size will be set once the first frame arrives
364
+ isOutputByteBuffer = true ;
360
365
}
361
366
#endif
362
367
if (depth > 0 ) {
@@ -383,7 +388,8 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
383
388
gboolean success = gst_buffer_map (buffer,&info, (GstMapFlags)GST_MAP_READ);
384
389
385
390
// with MJPEG streams frame size can change arbitrarily
386
- if (int (info.size ) != frame->imageSize ) {
391
+ if (isOutputByteBuffer && (size_t )info.size != (size_t )frame->imageSize )
392
+ {
387
393
cvReleaseImageHeader (&frame);
388
394
frame = cvCreateImageHeader (cvSize (info.size , 1 ), IPL_DEPTH_8U, 1 );
389
395
}
0 commit comments