Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
ee0c16e4
Commit
ee0c16e4
authored
Apr 23, 2011
by
Nils Hasler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* added property CV_CAP_GSTREAMER_QUEUE_LENGTH
* removed unnecessary memcpy * fixed minor memory leak
parent
6e15238d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
14 deletions
+48
-14
highgui_c.h
modules/highgui/include/opencv2/highgui/highgui_c.h
+5
-2
cap_gstreamer.cpp
modules/highgui/src/cap_gstreamer.cpp
+43
-12
No files found.
modules/highgui/include/opencv2/highgui/highgui_c.h
View file @
ee0c16e4
...
...
@@ -358,14 +358,17 @@ enum
CV_CAP_OPENNI_IMAGE_GENERATOR
=
1
<<
31
,
CV_CAP_OPENNI_GENERATORS_MASK
=
1
<<
31
,
// Properties of cameras ava
li
ble through OpenNI interfaces
// Properties of cameras ava
ila
ble through OpenNI interfaces
CV_CAP_PROP_OPENNI_OUTPUT_MODE
=
100
,
CV_CAP_PROP_OPENNI_FRAME_MAX_DEPTH
=
101
,
// in mm
CV_CAP_PROP_OPENNI_BASELINE
=
102
,
// in mm
CV_CAP_PROP_OPENNI_FOCAL_LENGTH
=
103
,
// in pixels
CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE
=
CV_CAP_OPENNI_IMAGE_GENERATOR
+
CV_CAP_PROP_OPENNI_OUTPUT_MODE
,
CV_CAP_OPENNI_DEPTH_GENERATOR_BASELINE
=
CV_CAP_OPENNI_DEPTH_GENERATOR
+
CV_CAP_PROP_OPENNI_BASELINE
,
CV_CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH
=
CV_CAP_OPENNI_DEPTH_GENERATOR
+
CV_CAP_PROP_OPENNI_FOCAL_LENGTH
CV_CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH
=
CV_CAP_OPENNI_DEPTH_GENERATOR
+
CV_CAP_PROP_OPENNI_FOCAL_LENGTH
,
// Properties of cameras available through GStreamer interface
CV_CAP_GSTREAMER_QUEUE_LENGTH
=
200
// default is 1
};
enum
...
...
modules/highgui/src/cap_gstreamer.cpp
View file @
ee0c16e4
...
...
@@ -104,6 +104,7 @@ protected:
GstCaps
*
caps
;
IplImage
*
frame
;
};
void
CvCapture_GStreamer
::
init
()
{
pipeline
=
0
;
...
...
@@ -185,7 +186,9 @@ bool CvCapture_GStreamer::grabFrame()
else
#endif
{
// printf("pulling buffer\n");
buffer
=
gst_app_sink_pull_buffer
(
GST_APP_SINK
(
sink
));
// printf("pulled buffer %p\n", GST_BUFFER_DATA(buffer));
}
if
(
!
buffer
)
return
false
;
...
...
@@ -201,6 +204,8 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
if
(
!
buffer
)
return
false
;
// printf("retrieving buffer %p\n", GST_BUFFER_DATA(buffer));
if
(
!
frame
)
{
gint
height
,
width
;
GstCaps
*
buff_caps
=
gst_buffer_get_caps
(
buffer
);
...
...
@@ -208,17 +213,18 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
GstStructure
*
structure
=
gst_caps_get_structure
(
buff_caps
,
0
);
if
(
!
gst_structure_get_int
(
structure
,
"width"
,
&
width
)
||
!
gst_structure_get_int
(
structure
,
"height"
,
&
height
))
!
gst_structure_get_int
(
structure
,
"height"
,
&
height
))
return
false
;
frame
=
cvCreateImage
(
cvSize
(
width
,
height
),
IPL_DEPTH_8U
,
3
);
frame
=
cvCreateImage
Header
(
cvSize
(
width
,
height
),
IPL_DEPTH_8U
,
3
);
gst_caps_unref
(
buff_caps
);
}
memcpy
(
frame
->
imageData
,
GST_BUFFER_DATA
(
buffer
),
GST_BUFFER_SIZE
(
buffer
));
frame
->
imageData
=
(
char
*
)
GST_BUFFER_DATA
(
buffer
);
//memcpy (frame->imageData, GST_BUFFER_DATA(buffer), GST_BUFFER_SIZE (buffer));
//gst_data_copy_into (frame->imageData,GST_BUFFER_DATA(buffer));
gst_buffer_unref
(
buffer
);
buffer
=
0
;
//
gst_buffer_unref(buffer);
//
buffer = 0;
return
frame
;
}
...
...
@@ -306,6 +312,14 @@ void CvCapture_GStreamer::newPad(GstElement *uridecodebin,
gst_object_unref
(
sinkpad
);
}
// static int buffernum = 0;
// static GstFlowReturn newbuffer(GstAppSink *sink, gpointer data)
// {
// printf("new buffer %d\n", buffernum);
// buffernum++;
// return GST_FLOW_OK;
// }
bool
CvCapture_GStreamer
::
open
(
int
type
,
const
char
*
filename
)
{
close
();
...
...
@@ -384,6 +398,8 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
if
(
stream
)
{
gst_app_sink_set_drop
(
GST_APP_SINK
(
sink
),
true
);
}
// GstAppSinkCallbacks cb = {0, 0, newbuffer, 0};
// gst_app_sink_set_callbacks(GST_APP_SINK(sink), &cb, 0, 0);
#else
sink
=
gst_element_factory_make
(
"opencv-appsink"
,
NULL
);
#endif
...
...
@@ -501,11 +517,11 @@ void CvVideoWriter_GStreamer::init()
}
void
CvVideoWriter_GStreamer
::
close
()
{
if
(
pipeline
)
{
gst_app_src_end_of_stream
(
GST_APP_SRC
(
source
));
gst_element_set_state
(
pipeline
,
GST_STATE_NULL
);
gst_object_unref
(
GST_OBJECT
(
pipeline
));
}
if
(
pipeline
)
{
gst_app_src_end_of_stream
(
GST_APP_SRC
(
source
));
gst_element_set_state
(
pipeline
,
GST_STATE_NULL
);
gst_object_unref
(
GST_OBJECT
(
pipeline
));
}
}
bool
CvVideoWriter_GStreamer
::
open
(
const
char
*
filename
,
int
fourcc
,
double
fps
,
CvSize
frameSize
,
bool
is_color
)
...
...
@@ -637,6 +653,10 @@ void CvCapture_GStreamer::close()
}
if
(
buffer
)
gst_buffer_unref
(
buffer
);
if
(
frame
)
{
frame
->
imageData
=
0
;
cvReleaseImage
(
&
frame
);
}
}
double
CvCapture_GStreamer
::
getProperty
(
int
propId
)
...
...
@@ -653,14 +673,14 @@ double CvCapture_GStreamer::getProperty( int propId )
switch
(
propId
)
{
case
CV_CAP_PROP_POS_MSEC
:
format
=
GST_FORMAT_TIME
;
if
(
!
gst_element_query_position
(
pipeline
,
&
format
,
&
value
))
{
if
(
!
gst_element_query_position
(
sink
,
&
format
,
&
value
))
{
CV_WARN
(
"GStreamer: unable to query position of stream"
);
return
false
;
}
return
value
*
1e-6
;
// nano seconds to milli seconds
case
CV_CAP_PROP_POS_FRAMES
:
format
=
GST_FORMAT_DEFAULT
;
if
(
!
gst_element_query_position
(
pipeline
,
&
format
,
&
value
))
{
if
(
!
gst_element_query_position
(
sink
,
&
format
,
&
value
))
{
CV_WARN
(
"GStreamer: unable to query position of stream"
);
return
false
;
}
...
...
@@ -693,6 +713,12 @@ double CvCapture_GStreamer::getProperty( int propId )
case
CV_CAP_PROP_GAIN
:
case
CV_CAP_PROP_CONVERT_RGB
:
break
;
case
CV_CAP_GSTREAMER_QUEUE_LENGTH
:
if
(
!
sink
)
{
CV_WARN
(
"GStreamer: there is no sink yet"
);
return
false
;
}
return
gst_app_sink_get_max_buffers
(
GST_APP_SINK
(
sink
));
default
:
CV_WARN
(
"GStreamer: unhandled property"
);
break
;
...
...
@@ -772,6 +798,11 @@ bool CvCapture_GStreamer::setProperty( int propId, double value )
case
CV_CAP_PROP_GAIN
:
case
CV_CAP_PROP_CONVERT_RGB
:
break
;
case
CV_CAP_GSTREAMER_QUEUE_LENGTH
:
if
(
!
sink
)
break
;
gst_app_sink_set_max_buffers
(
GST_APP_SINK
(
sink
),
(
guint
)
value
);
break
;
default
:
CV_WARN
(
"GStreamer: unhandled property"
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment