Commit 53098323 authored by Maksim Shabunin's avatar Maksim Shabunin

VideoIO: prettier test console output, gstreamer capture backend changed to C++ interface

parent 9615f8c9
...@@ -40,6 +40,8 @@ ...@@ -40,6 +40,8 @@
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include <iostream>
using namespace std;
#include "cap_intelperc.hpp" #include "cap_intelperc.hpp"
#include "cap_dshow.hpp" #include "cap_dshow.hpp"
...@@ -200,12 +202,6 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index) ...@@ -200,12 +202,6 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
TRY_OPEN(capture, cvCreateCameraCapture_V4L(index)) TRY_OPEN(capture, cvCreateCameraCapture_V4L(index))
#endif #endif
#ifdef HAVE_GSTREAMER
TRY_OPEN(capture, cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L2, reinterpret_cast<char *>(index)))
TRY_OPEN(capture, cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L, reinterpret_cast<char *>(index)))
#endif
if (pref) break; // CAP_VFW or CAP_V4L or CAP_V4L2 if (pref) break; // CAP_VFW or CAP_V4L or CAP_V4L2
case CAP_FIREWIRE: case CAP_FIREWIRE:
...@@ -221,11 +217,6 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index) ...@@ -221,11 +217,6 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
TRY_OPEN(capture, cvCreateCameraCapture_CMU(index)) TRY_OPEN(capture, cvCreateCameraCapture_CMU(index))
#endif #endif
#if defined(HAVE_GSTREAMER) && 0
// Re-enable again when gstreamer 1394 support will land in the backend code
TRY_OPEN(capture, cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_1394, 0))
#endif
if (pref) break; // CAP_FIREWIRE if (pref) break; // CAP_FIREWIRE
#ifdef HAVE_MIL #ifdef HAVE_MIL
...@@ -330,12 +321,6 @@ CV_IMPL CvCapture * cvCreateFileCaptureWithPreference (const char * filename, in ...@@ -330,12 +321,6 @@ CV_IMPL CvCapture * cvCreateFileCaptureWithPreference (const char * filename, in
if (apiPreference) break; if (apiPreference) break;
#endif #endif
#ifdef HAVE_GSTREAMER
case CAP_GSTREAMER:
TRY_OPEN(result, cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename))
if (apiPreference) break;
#endif
#if defined(HAVE_QUICKTIME) || defined(HAVE_QTKIT) #if defined(HAVE_QUICKTIME) || defined(HAVE_QTKIT)
case CAP_QT: case CAP_QT:
TRY_OPEN(result, cvCreateFileCapture_QT (filename)) TRY_OPEN(result, cvCreateFileCapture_QT (filename))
...@@ -463,6 +448,9 @@ static Ptr<IVideoCapture> IVideoCapture_create(int index) ...@@ -463,6 +448,9 @@ static Ptr<IVideoCapture> IVideoCapture_create(int index)
{ {
int domains[] = int domains[] =
{ {
#ifdef HAVE_GSTREAMER
CAP_GSTREAMER,
#endif
#ifdef HAVE_DSHOW #ifdef HAVE_DSHOW
CAP_DSHOW, CAP_DSHOW,
#endif #endif
...@@ -490,7 +478,8 @@ static Ptr<IVideoCapture> IVideoCapture_create(int index) ...@@ -490,7 +478,8 @@ static Ptr<IVideoCapture> IVideoCapture_create(int index)
// try every possibly installed camera API // try every possibly installed camera API
for (int i = 0; domains[i] >= 0; i++) for (int i = 0; domains[i] >= 0; i++)
{ {
#if defined(HAVE_DSHOW) || \ #if defined(HAVE_GSTREAMER) || \
defined(HAVE_DSHOW) || \
defined(HAVE_INTELPERC) || \ defined(HAVE_INTELPERC) || \
defined(WINRT_VIDEO) || \ defined(WINRT_VIDEO) || \
defined(HAVE_GPHOTO2) || \ defined(HAVE_GPHOTO2) || \
...@@ -499,6 +488,11 @@ static Ptr<IVideoCapture> IVideoCapture_create(int index) ...@@ -499,6 +488,11 @@ static Ptr<IVideoCapture> IVideoCapture_create(int index)
switch (domains[i]) switch (domains[i])
{ {
#ifdef HAVE_GSTREAMER
case CAP_GSTREAMER:
capture = createGStreamerCapture(index);
break;
#endif
#ifdef HAVE_DSHOW #ifdef HAVE_DSHOW
case CAP_DSHOW: case CAP_DSHOW:
capture = makePtr<VideoCapture_DShow>(index); capture = makePtr<VideoCapture_DShow>(index);
...@@ -536,6 +530,14 @@ static Ptr<IVideoCapture> IVideoCapture_create(const String& filename, int apiPr ...@@ -536,6 +530,14 @@ static Ptr<IVideoCapture> IVideoCapture_create(const String& filename, int apiPr
{ {
bool useAny = (apiPreference == CAP_ANY); bool useAny = (apiPreference == CAP_ANY);
Ptr<IVideoCapture> capture; Ptr<IVideoCapture> capture;
#ifdef HAVE_GSTREAMER
if (useAny || apiPreference == CAP_GSTREAMER)
{
capture = createGStreamerCapture(filename);
if (capture && capture->isOpened())
return capture;
}
#endif
#ifdef HAVE_XINE #ifdef HAVE_XINE
if (useAny || apiPreference == CAP_XINE) if (useAny || apiPreference == CAP_XINE)
{ {
......
This diff is collapsed.
...@@ -139,7 +139,6 @@ CvVideoWriter* cvCreateVideoWriter_Images(const char* filename); ...@@ -139,7 +139,6 @@ CvVideoWriter* cvCreateVideoWriter_Images(const char* filename);
#define CV_CAP_GSTREAMER_V4L2 2 #define CV_CAP_GSTREAMER_V4L2 2
#define CV_CAP_GSTREAMER_FILE 3 #define CV_CAP_GSTREAMER_FILE 3
CvCapture* cvCreateCapture_GStreamer(int type, const char *filename);
CvCapture* cvCreateFileCapture_FFMPEG_proxy(const char* filename); CvCapture* cvCreateFileCapture_FFMPEG_proxy(const char* filename);
...@@ -194,7 +193,11 @@ namespace cv ...@@ -194,7 +193,11 @@ namespace cv
Ptr<IVideoCapture> createGPhoto2Capture(int index); Ptr<IVideoCapture> createGPhoto2Capture(int index);
Ptr<IVideoCapture> createGPhoto2Capture(const String& deviceName); Ptr<IVideoCapture> createGPhoto2Capture(const String& deviceName);
Ptr<IVideoCapture> createXINECapture(const char* filename); Ptr<IVideoCapture> createXINECapture(const char* filename);
Ptr<IVideoCapture> createGStreamerCapture(const String& filename);
Ptr<IVideoCapture> createGStreamerCapture(int index);
} }
#endif /* __VIDEOIO_H_ */ #endif /* __VIDEOIO_H_ */
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
namespace opencv_test namespace opencv_test
{ {
typedef tuple< string, Size, Size, int > Param; typedef tuple< string, Size, Size, int > Param;
typedef testing::TestWithParam< Param > Videoio_Gstreamer_Test; typedef testing::TestWithParam< Param > Videoio_Gstreamer_Test;
...@@ -19,8 +20,9 @@ TEST_P(Videoio_Gstreamer_Test, test_object_structure) ...@@ -19,8 +20,9 @@ TEST_P(Videoio_Gstreamer_Test, test_object_structure)
int count_frames = 10; int count_frames = 10;
std::ostringstream pipeline; std::ostringstream pipeline;
pipeline << "videotestsrc pattern=ball num-buffers=" << count_frames << " ! " << format; pipeline << "videotestsrc pattern=ball num-buffers=" << count_frames << " ! " << format;
pipeline << ", framerate=1/1, width=" << frame_size.width << ", height=" << frame_size.height << " ! appsink"; pipeline << ", width=" << frame_size.width << ", height=" << frame_size.height << " ! appsink";
VideoCapture cap(pipeline.str(), CAP_GSTREAMER); VideoCapture cap;
ASSERT_NO_THROW(cap.open(pipeline.str(), CAP_GSTREAMER));
ASSERT_TRUE(cap.isOpened()); ASSERT_TRUE(cap.isOpened());
Mat buffer, decode_frame, gray_frame, rgb_frame; Mat buffer, decode_frame, gray_frame, rgb_frame;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment