Merge pull request #6201 from paroj:gst_noconvert
This commit is contained in:
commit
88a33a4e4f
@ -292,18 +292,22 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
|
|||||||
const gchar* name = gst_structure_get_name(structure);
|
const gchar* name = gst_structure_get_name(structure);
|
||||||
const gchar* format = gst_structure_get_string(structure, "format");
|
const gchar* format = gst_structure_get_string(structure, "format");
|
||||||
|
|
||||||
if (!name || !format)
|
if (!name)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// we support 3 types of data:
|
// we support 3 types of data:
|
||||||
// video/x-raw, format=BGR -> 8bit, 3 channels
|
// video/x-raw, format=BGR -> 8bit, 3 channels
|
||||||
// video/x-raw, format=GRAY8 -> 8bit, 1 channel
|
// video/x-raw, format=GRAY8 -> 8bit, 1 channel
|
||||||
// video/x-bayer -> 8bit, 1 channel
|
// video/x-bayer -> 8bit, 1 channel
|
||||||
|
// image/jpeg -> 8bit, mjpeg: buffer_size x 1 x 1
|
||||||
// bayer data is never decoded, the user is responsible for that
|
// bayer data is never decoded, the user is responsible for that
|
||||||
// everything is 8 bit, so we just test the caps for bit depth
|
// everything is 8 bit, so we just test the caps for bit depth
|
||||||
|
|
||||||
if (strcasecmp(name, "video/x-raw") == 0)
|
if (strcasecmp(name, "video/x-raw") == 0)
|
||||||
{
|
{
|
||||||
|
if (!format)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (strcasecmp(format, "BGR") == 0) {
|
if (strcasecmp(format, "BGR") == 0) {
|
||||||
depth = 3;
|
depth = 3;
|
||||||
}
|
}
|
||||||
@ -314,6 +318,9 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
|
|||||||
else if (strcasecmp(name, "video/x-bayer") == 0)
|
else if (strcasecmp(name, "video/x-bayer") == 0)
|
||||||
{
|
{
|
||||||
depth = 1;
|
depth = 1;
|
||||||
|
} else if(strcasecmp(name, "image/jpeg") == 0) {
|
||||||
|
depth = 1;
|
||||||
|
// the correct size will be set once the first frame arrives
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (depth > 0) {
|
if (depth > 0) {
|
||||||
@ -334,6 +341,13 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
|
|||||||
// info.data ptr is valid until next grabFrame where the associated sample is unref'd
|
// info.data ptr is valid until next grabFrame where the associated sample is unref'd
|
||||||
GstMapInfo info = GstMapInfo();
|
GstMapInfo info = GstMapInfo();
|
||||||
gboolean success = gst_buffer_map(buffer,&info, (GstMapFlags)GST_MAP_READ);
|
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) {
|
||||||
|
cvReleaseImageHeader(&frame);
|
||||||
|
frame = cvCreateImageHeader(cvSize(info.size, 1), IPL_DEPTH_8U, 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (!success){
|
if (!success){
|
||||||
//something weird went wrong here. abort. abort.
|
//something weird went wrong here. abort. abort.
|
||||||
//fprintf(stderr,"GStreamer: unable to map buffer");
|
//fprintf(stderr,"GStreamer: unable to map buffer");
|
||||||
@ -797,7 +811,7 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
|
|||||||
NULL);
|
NULL);
|
||||||
#else
|
#else
|
||||||
// support 1 and 3 channel 8 bit data, as well as bayer (also 1 channel, 8bit)
|
// support 1 and 3 channel 8 bit data, as well as bayer (also 1 channel, 8bit)
|
||||||
caps = gst_caps_from_string("video/x-raw, format=(string){BGR, GRAY8}; video/x-bayer,format=(string){rggb,bggr,grbg,gbrg}");
|
caps = gst_caps_from_string("video/x-raw, format=(string){BGR, GRAY8}; video/x-bayer,format=(string){rggb,bggr,grbg,gbrg}; image/jpeg");
|
||||||
#endif
|
#endif
|
||||||
gst_app_sink_set_caps(GST_APP_SINK(sink), caps);
|
gst_app_sink_set_caps(GST_APP_SINK(sink), caps);
|
||||||
gst_caps_unref(caps);
|
gst_caps_unref(caps);
|
||||||
|
Loading…
Reference in New Issue
Block a user