mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
e9982e856f
Open VideoCapture from data stream #25584 ### Pull Request Readiness Checklist Add VideoCapture option to read a raw binary video data from `std::streambuf`. There are multiple motivations: 1. Avoid disk file creation in case of video already in memory (received by network or from database). 2. Streaming mode. Frames decoding starts during sequential file transfer by chunks. Suppoted backends: * FFmpeg * MSMF (no streaming mode) Supporter interfaces: * C++ (std::streambuf) * Python (io.BufferedIOBase) resolves https://github.com/opencv/opencv/issues/24400 - [x] test h264 - [x] test IP camera like approach with no metadata but key frame only? - [x] C API plugin See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
50 lines
1.6 KiB
C++
50 lines
1.6 KiB
C++
// 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_VIDEOIO_REGISTRY_HPP__
|
|
#define __OPENCV_VIDEOIO_VIDEOIO_REGISTRY_HPP__
|
|
|
|
#include "backend.hpp"
|
|
|
|
namespace cv
|
|
{
|
|
|
|
/** Capabilities bitmask */
|
|
enum BackendMode {
|
|
MODE_CAPTURE_BY_INDEX = 1 << 0, //!< device index
|
|
MODE_CAPTURE_BY_FILENAME = 1 << 1, //!< filename or device path (v4l2)
|
|
MODE_CAPTURE_BY_STREAM = 1 << 2, //!< data stream
|
|
MODE_WRITER = 1 << 4, //!< writer
|
|
|
|
MODE_CAPTURE_ALL = MODE_CAPTURE_BY_INDEX + MODE_CAPTURE_BY_FILENAME,
|
|
};
|
|
|
|
struct VideoBackendInfo {
|
|
VideoCaptureAPIs id;
|
|
BackendMode mode;
|
|
int priority; // 1000-<index*10> - default builtin priority
|
|
// 0 - disabled (OPENCV_VIDEOIO_PRIORITY_<name> = 0)
|
|
// >10000 - prioritized list (OPENCV_VIDEOIO_PRIORITY_LIST)
|
|
const char* name;
|
|
Ptr<IBackendFactory> backendFactory;
|
|
};
|
|
|
|
struct VideoDeprecatedBackendInfo {
|
|
VideoCaptureAPIs id;
|
|
const char* name;
|
|
};
|
|
|
|
namespace videoio_registry {
|
|
|
|
std::vector<VideoBackendInfo> getAvailableBackends_CaptureByIndex();
|
|
std::vector<VideoBackendInfo> getAvailableBackends_CaptureByFilename();
|
|
std::vector<VideoBackendInfo> getAvailableBackends_CaptureByStream();
|
|
std::vector<VideoBackendInfo> getAvailableBackends_Writer();
|
|
bool checkDeprecatedBackend(int api);
|
|
|
|
} // namespace
|
|
|
|
} // namespace
|
|
#endif // __OPENCV_VIDEOIO_VIDEOIO_REGISTRY_HPP__
|