mirror of
https://github.com/zebrajr/opencv.git
synced 2025-12-06 12:19:50 +01:00
Merge pull request #27546 from asmorkalov:as/interactive_calib_backend
Added command line option to select VideoCapture backend
This commit is contained in:
commit
4813d1cd32
|
|
@ -92,6 +92,7 @@ namespace calib
|
|||
std::string videoFileName;
|
||||
bool flipVertical;
|
||||
int camID;
|
||||
int camBackend;
|
||||
int fps;
|
||||
cv::Size cameraResolution;
|
||||
int maxFramesNum;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ PipelineExitStatus CalibPipeline::start(std::vector<cv::Ptr<FrameProcessor> > pr
|
|||
auto open_camera = [this] () {
|
||||
if(mCaptureParams.source == Camera)
|
||||
{
|
||||
mCapture.open(mCaptureParams.camID);
|
||||
mCapture.open(mCaptureParams.camID, mCaptureParams.camBackend);
|
||||
cv::Size maxRes = getCameraResolution();
|
||||
cv::Size neededRes = mCaptureParams.cameraResolution;
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ PipelineExitStatus CalibPipeline::start(std::vector<cv::Ptr<FrameProcessor> > pr
|
|||
mCapture.set(cv::CAP_PROP_AUTOFOCUS, 0);
|
||||
}
|
||||
else if (mCaptureParams.source == File)
|
||||
mCapture.open(mCaptureParams.videoFileName);
|
||||
mCapture.open(mCaptureParams.videoFileName, mCaptureParams.camBackend);
|
||||
};
|
||||
|
||||
if(!mCapture.isOpened()) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#include <opencv2/calib3d.hpp>
|
||||
#include <opencv2/cvconfig.h>
|
||||
#include <opencv2/highgui.hpp>
|
||||
|
||||
#include <opencv2/videoio/registry.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
|
@ -23,9 +23,25 @@
|
|||
|
||||
using namespace calib;
|
||||
|
||||
const std::string keys =
|
||||
static std::string getVideoIoBackendsString()
|
||||
{
|
||||
std::string result;
|
||||
auto backs = cv::videoio_registry::getBackends();
|
||||
for (const auto& b: backs)
|
||||
{
|
||||
if (!result.empty())
|
||||
result += ", ";
|
||||
|
||||
result += cv::videoio_registry::getBackendName(b);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const char* keys =
|
||||
"{v | | Input from video file }"
|
||||
"{ci | 0 | Default camera id }"
|
||||
"{ci | 0 | Camera id }"
|
||||
"{vb | | Video I/O back-end. One of: %s }"
|
||||
"{flip | false | Vertical flip of input frames }"
|
||||
"{t | circles | Template for calibration (circles, chessboard, dualCircles, charuco, symcircles) }"
|
||||
"{sz | 16.3 | Distance between two nearest centers of circles or squares on calibration board}"
|
||||
|
|
@ -95,11 +111,13 @@ static void undistortButton(int state, void* data)
|
|||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
cv::CommandLineParser parser(argc, argv, keys);
|
||||
cv::CommandLineParser parser(argc, argv, cv::format(keys, getVideoIoBackendsString().c_str()));
|
||||
|
||||
if(parser.has("help")) {
|
||||
parser.printMessage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::cout << consoleHelp << std::endl;
|
||||
parametersController paramsController;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "parametersController.hpp"
|
||||
#include <opencv2/objdetect/aruco_dictionary.hpp>
|
||||
|
||||
#include <opencv2/videoio/registry.hpp>
|
||||
#include <iostream>
|
||||
|
||||
template <typename T>
|
||||
|
|
@ -106,6 +106,27 @@ bool calib::parametersController::loadFromParser(cv::CommandLineParser &parser)
|
|||
mCapParams.camID = parser.get<int>("ci");
|
||||
}
|
||||
|
||||
mCapParams.camBackend = cv::CAP_ANY;
|
||||
if (parser.has("vb"))
|
||||
{
|
||||
std::string backendName = parser.get<std::string>("vb");
|
||||
auto backs = cv::videoio_registry::getBackends();
|
||||
bool backendSet = false;
|
||||
for (const auto& b: backs)
|
||||
{
|
||||
if (backendName == cv::videoio_registry::getBackendName(b))
|
||||
{
|
||||
mCapParams.camBackend = b;
|
||||
backendSet = true;
|
||||
}
|
||||
}
|
||||
if (!backendSet)
|
||||
{
|
||||
std::cout << "Unknown or unsupported backend " << backendName << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::string templateType = parser.get<std::string>("t");
|
||||
|
||||
if(templateType.find("symcircles", 0) == 0) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user