mirror of https://github.com/opencv/opencv.git
into cv::videoio_registry namespacepull/12020/head
parent
905da2994a
commit
270cc3bcbc
8 changed files with 213 additions and 57 deletions
@ -0,0 +1,25 @@ |
||||
#!/usr/bin/env python |
||||
from __future__ import print_function |
||||
|
||||
import numpy as np |
||||
import cv2 as cv |
||||
|
||||
from tests_common import NewOpenCVTests |
||||
|
||||
class Bindings(NewOpenCVTests): |
||||
|
||||
def check_name(self, name): |
||||
#print(name) |
||||
self.assertFalse(name == None) |
||||
self.assertFalse(name == "") |
||||
|
||||
def test_registry(self): |
||||
self.check_name(cv.videoio_registry.getBackendName(cv.CAP_ANY)); |
||||
self.check_name(cv.videoio_registry.getBackendName(cv.CAP_FFMPEG)) |
||||
self.check_name(cv.videoio_registry.getBackendName(cv.CAP_OPENCV_MJPEG)) |
||||
backends = cv.videoio_registry.getBackends() |
||||
for backend in backends: |
||||
self.check_name(cv.videoio_registry.getBackendName(backend)) |
||||
|
||||
if __name__ == '__main__': |
||||
NewOpenCVTests.bootstrap() |
@ -0,0 +1,44 @@ |
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
#ifndef OPENCV_VIDEOIO_REGISTRY_HPP |
||||
#define OPENCV_VIDEOIO_REGISTRY_HPP |
||||
|
||||
#include <opencv2/videoio.hpp> |
||||
|
||||
namespace cv { namespace videoio_registry { |
||||
/** @addtogroup videoio_registry
|
||||
This section contains API description how to query/configure available Video I/O backends. |
||||
|
||||
Runtime configuration options: |
||||
- enable debug mode: `OPENCV_VIDEOIO_DEBUG=1` |
||||
- change backend priority: `OPENCV_VIDEOIO_PRIORITY_<backend>=9999` |
||||
- disable backend: `OPENCV_VIDEOIO_PRIORITY_<backend>=0` |
||||
- specify list of backends with high priority (>100000): `OPENCV_VIDEOIO_PRIORITY_LIST=FFMPEG,GSTREAMER` |
||||
|
||||
@{ |
||||
*/ |
||||
|
||||
|
||||
/** @brief Returns backend API name or "unknown"
|
||||
@param api backend ID (#VideoCaptureAPIs) |
||||
*/ |
||||
CV_EXPORTS_W cv::String getBackendName(VideoCaptureAPIs api); |
||||
|
||||
/** @brief Returns list of all builtin backends */ |
||||
CV_EXPORTS_W std::vector<VideoCaptureAPIs> getBackends(); |
||||
|
||||
/** @brief Returns list of available backends which works via `cv::VideoCapture(int index)` */ |
||||
CV_EXPORTS_W std::vector<VideoCaptureAPIs> getCameraBackends(); |
||||
|
||||
/** @brief Returns list of available backends which works via `cv::VideoCapture(filename)` */ |
||||
CV_EXPORTS_W std::vector<VideoCaptureAPIs> getStreamBackends(); |
||||
|
||||
/** @brief Returns list of available backends which works via `cv::VideoWriter()` */ |
||||
CV_EXPORTS_W std::vector<VideoCaptureAPIs> getWriterBackends(); |
||||
|
||||
//! @}
|
||||
}} // namespace
|
||||
|
||||
#endif // OPENCV_VIDEOIO_REGISTRY_HPP
|
@ -0,0 +1,50 @@ |
||||
#ifdef HAVE_OPENCV_VIDEOIO |
||||
typedef std::vector<VideoCaptureAPIs> vector_VideoCaptureAPIs; |
||||
|
||||
template<> |
||||
bool pyopencv_to(PyObject *o, cv::VideoCaptureAPIs &v, const char *name) |
||||
{ |
||||
(void)name; |
||||
v = CAP_ANY; |
||||
if (!o || o == Py_None) |
||||
return false; |
||||
else if (PyLong_Check(o)) |
||||
{ |
||||
v = VideoCaptureAPIs((int64)PyLong_AsLongLong(o)); |
||||
return true; |
||||
} |
||||
else if (PyInt_Check(o)) |
||||
{ |
||||
v = VideoCaptureAPIs((int64)PyInt_AS_LONG(o)); |
||||
return true; |
||||
} |
||||
else |
||||
return false; |
||||
} |
||||
|
||||
template<> |
||||
PyObject* pyopencv_from(const cv::VideoCaptureAPIs &v) |
||||
{ |
||||
return pyopencv_from((int)(v)); |
||||
} |
||||
|
||||
template<> struct pyopencvVecConverter<cv::VideoCaptureAPIs> |
||||
{ |
||||
static bool to(PyObject* obj, std::vector<cv::VideoCaptureAPIs>& value, const ArgInfo info) |
||||
{ |
||||
return pyopencv_to_generic_vec(obj, value, info); |
||||
} |
||||
|
||||
static PyObject* from(const std::vector<cv::VideoCaptureAPIs>& value) |
||||
{ |
||||
return pyopencv_from_generic_vec(value); |
||||
} |
||||
}; |
||||
|
||||
template<> |
||||
bool pyopencv_to(PyObject *o, std::vector<cv::VideoCaptureAPIs>& apis, const char *name) |
||||
{ |
||||
return pyopencvVecConverter<cv::VideoCaptureAPIs>::to(o, apis, ArgInfo(name, false)); |
||||
} |
||||
|
||||
#endif // HAVE_OPENCV_VIDEOIO
|
Loading…
Reference in new issue