Merge pull request #22147 from rogday:zoom_factor
Add zoom factor to interactive calibration tool * add zoom factor * address review comments
This commit is contained in:
parent
2a4926f417
commit
b91f173680
@ -94,6 +94,7 @@ namespace calib
|
|||||||
int maxFramesNum;
|
int maxFramesNum;
|
||||||
int minFramesNum;
|
int minFramesNum;
|
||||||
bool saveFrames;
|
bool saveFrames;
|
||||||
|
float zoom;
|
||||||
|
|
||||||
captureParameters()
|
captureParameters()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
#include "calibPipeline.hpp"
|
#include "calibPipeline.hpp"
|
||||||
|
|
||||||
#include <opencv2/highgui.hpp>
|
#include <opencv2/highgui.hpp>
|
||||||
|
#include <opencv2/imgproc.hpp>
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ PipelineExitStatus CalibPipeline::start(std::vector<cv::Ptr<FrameProcessor> > pr
|
|||||||
if(!mCapture.isOpened())
|
if(!mCapture.isOpened())
|
||||||
throw std::runtime_error("Unable to open video source");
|
throw std::runtime_error("Unable to open video source");
|
||||||
|
|
||||||
cv::Mat frame, processedFrame;
|
cv::Mat frame, processedFrame, resizedFrame;
|
||||||
while(mCapture.grab()) {
|
while(mCapture.grab()) {
|
||||||
mCapture.retrieve(frame);
|
mCapture.retrieve(frame);
|
||||||
if(mCaptureParams.flipVertical)
|
if(mCaptureParams.flipVertical)
|
||||||
@ -67,7 +68,15 @@ PipelineExitStatus CalibPipeline::start(std::vector<cv::Ptr<FrameProcessor> > pr
|
|||||||
frame.copyTo(processedFrame);
|
frame.copyTo(processedFrame);
|
||||||
for (std::vector<cv::Ptr<FrameProcessor> >::iterator it = processors.begin(); it != processors.end(); ++it)
|
for (std::vector<cv::Ptr<FrameProcessor> >::iterator it = processors.begin(); it != processors.end(); ++it)
|
||||||
processedFrame = (*it)->processFrame(processedFrame);
|
processedFrame = (*it)->processFrame(processedFrame);
|
||||||
cv::imshow(mainWindowName, processedFrame);
|
if (std::fabs(mCaptureParams.zoom - 1.) > 0.001f)
|
||||||
|
{
|
||||||
|
cv::resize(processedFrame, resizedFrame, cv::Size(), mCaptureParams.zoom, mCaptureParams.zoom);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
resizedFrame = std::move(processedFrame);
|
||||||
|
}
|
||||||
|
cv::imshow(mainWindowName, resizedFrame);
|
||||||
char key = (char)cv::waitKey(CAP_DELAY);
|
char key = (char)cv::waitKey(CAP_DELAY);
|
||||||
|
|
||||||
if(key == 27) // esc
|
if(key == 27) // esc
|
||||||
|
|||||||
@ -201,7 +201,16 @@ void CalibProcessor::showCaptureMessage(const cv::Mat& frame, const std::string
|
|||||||
double textSize = VIDEO_TEXT_SIZE * frame.cols / (double) IMAGE_MAX_WIDTH;
|
double textSize = VIDEO_TEXT_SIZE * frame.cols / (double) IMAGE_MAX_WIDTH;
|
||||||
cv::bitwise_not(frame, frame);
|
cv::bitwise_not(frame, frame);
|
||||||
cv::putText(frame, message, textOrigin, 1, textSize, cv::Scalar(0,0,255), 2, cv::LINE_AA);
|
cv::putText(frame, message, textOrigin, 1, textSize, cv::Scalar(0,0,255), 2, cv::LINE_AA);
|
||||||
cv::imshow(mainWindowName, frame);
|
cv::Mat resized;
|
||||||
|
if (std::fabs(mZoom - 1.) > 0.001f)
|
||||||
|
{
|
||||||
|
cv::resize(frame, resized, cv::Size(), mZoom, mZoom);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
resized = frame;
|
||||||
|
}
|
||||||
|
cv::imshow(mainWindowName, resized);
|
||||||
cv::waitKey(300);
|
cv::waitKey(300);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,6 +276,7 @@ CalibProcessor::CalibProcessor(cv::Ptr<calibrationData> data, captureParameters
|
|||||||
mSquareSize = capParams.squareSize;
|
mSquareSize = capParams.squareSize;
|
||||||
mTemplDist = capParams.templDst;
|
mTemplDist = capParams.templDst;
|
||||||
mSaveFrames = capParams.saveFrames;
|
mSaveFrames = capParams.saveFrames;
|
||||||
|
mZoom = capParams.zoom;
|
||||||
|
|
||||||
switch(mBoardType)
|
switch(mBoardType)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -51,6 +51,7 @@ protected:
|
|||||||
float mSquareSize;
|
float mSquareSize;
|
||||||
float mTemplDist;
|
float mTemplDist;
|
||||||
bool mSaveFrames;
|
bool mSaveFrames;
|
||||||
|
float mZoom;
|
||||||
|
|
||||||
bool detectAndParseChessboard(const cv::Mat& frame);
|
bool detectAndParseChessboard(const cv::Mat& frame);
|
||||||
bool detectAndParseChAruco(const cv::Mat& frame);
|
bool detectAndParseChAruco(const cv::Mat& frame);
|
||||||
|
|||||||
@ -41,6 +41,7 @@ const std::string keys =
|
|||||||
"{d | 0.8 | Min delay between captures}"
|
"{d | 0.8 | Min delay between captures}"
|
||||||
"{pf | defaultConfig.xml| Advanced application parameters}"
|
"{pf | defaultConfig.xml| Advanced application parameters}"
|
||||||
"{save_frames | false | Save frames that contribute to final calibration}"
|
"{save_frames | false | Save frames that contribute to final calibration}"
|
||||||
|
"{zoom | 1 | Zoom factor applied to the image}"
|
||||||
"{help | | Print help}";
|
"{help | | Print help}";
|
||||||
|
|
||||||
bool calib::showOverlayMessage(const std::string& message)
|
bool calib::showOverlayMessage(const std::string& message)
|
||||||
|
|||||||
@ -90,6 +90,7 @@ bool calib::parametersController::loadFromParser(cv::CommandLineParser &parser)
|
|||||||
mCapParams.squareSize = parser.get<float>("sz");
|
mCapParams.squareSize = parser.get<float>("sz");
|
||||||
mCapParams.templDst = parser.get<float>("dst");
|
mCapParams.templDst = parser.get<float>("dst");
|
||||||
mCapParams.saveFrames = parser.has("save_frames");
|
mCapParams.saveFrames = parser.has("save_frames");
|
||||||
|
mCapParams.zoom = parser.get<float>("zoom");
|
||||||
|
|
||||||
if(!checkAssertion(mCapParams.squareSize > 0, "Distance between corners or circles must be positive"))
|
if(!checkAssertion(mCapParams.squareSize > 0, "Distance between corners or circles must be positive"))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user