Skip to content

Commit

Permalink
videoio: improve condition for MJPEG gstreamer sink
Browse files Browse the repository at this point in the history
  • Loading branch information
alalek committed Nov 2, 2017
1 parent 942672a commit b1b2528
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion modules/videoio/src/cap_gstreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ class CvCapture_GStreamer : public CvCapture
bool isPosFramesSupported;
bool isPosFramesEmulated;
gint64 emulatedFrameNumber;

bool isOutputByteBuffer;
};

/*!
Expand Down Expand Up @@ -205,6 +207,8 @@ void CvCapture_GStreamer::init()
isPosFramesSupported = false;
isPosFramesEmulated = false;
emulatedFrameNumber = -1;

isOutputByteBuffer = false;
}

/*!
Expand Down Expand Up @@ -357,6 +361,7 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
} else if(strcasecmp(name, "image/jpeg") == 0) {
depth = 1;
// the correct size will be set once the first frame arrives
isOutputByteBuffer = true;
}
#endif
if (depth > 0) {
Expand All @@ -383,7 +388,8 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
gboolean success = gst_buffer_map(buffer,&info, (GstMapFlags)GST_MAP_READ);

// with MJPEG streams frame size can change arbitrarily
if(int(info.size) != frame->imageSize) {
if (isOutputByteBuffer && (size_t)info.size != (size_t)frame->imageSize)
{
cvReleaseImageHeader(&frame);
frame = cvCreateImageHeader(cvSize(info.size, 1), IPL_DEPTH_8U, 1);
}
Expand Down

0 comments on commit b1b2528

Please sign in to comment.