mirror of
https://github.com/opencv/opencv.git
synced 2025-08-05 22:19:14 +08:00
videoio: improve condition for MJPEG gstreamer sink
This commit is contained in:
parent
942672ad91
commit
b1b2528e50
@ -178,6 +178,8 @@ protected:
|
||||
bool isPosFramesSupported;
|
||||
bool isPosFramesEmulated;
|
||||
gint64 emulatedFrameNumber;
|
||||
|
||||
bool isOutputByteBuffer;
|
||||
};
|
||||
|
||||
/*!
|
||||
@ -205,6 +207,8 @@ void CvCapture_GStreamer::init()
|
||||
isPosFramesSupported = false;
|
||||
isPosFramesEmulated = false;
|
||||
emulatedFrameNumber = -1;
|
||||
|
||||
isOutputByteBuffer = false;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -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) {
|
||||
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user