2016-09-14 17:16:10 +08:00
|
|
|
// 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.
|
|
|
|
|
2016-04-08 21:30:56 +08:00
|
|
|
#ifndef FRAME_PROCESSOR_HPP
|
|
|
|
#define FRAME_PROCESSOR_HPP
|
|
|
|
|
|
|
|
#include <opencv2/core.hpp>
|
2020-12-02 04:42:15 +08:00
|
|
|
#include <opencv2/calib.hpp>
|
Merge pull request #22986 from AleksandrPanov:move_contrib_charuco_to_main_objdetect
merge with https://github.com/opencv/opencv_contrib/pull/3394
move Charuco API from contrib to main repo:
- add CharucoDetector:
```
CharucoDetector::detectBoard(InputArray image, InputOutputArrayOfArrays markerCorners, InputOutputArray markerIds,
OutputArray charucoCorners, OutputArray charucoIds) const // detect charucoCorners and/or markerCorners
CharucoDetector::detectDiamonds(InputArray image, InputOutputArrayOfArrays _markerCorners,
InputOutputArrayOfArrays _markerIds, OutputArrayOfArrays _diamondCorners,
OutputArray _diamondIds) const
```
- add `matchImagePoints()` for `CharucoBoard`
- remove contrib aruco dependencies from interactive-calibration tool
- move almost all aruco tests to objdetect
### Pull Request Readiness Checklist
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
2022-12-28 22:28:59 +08:00
|
|
|
#include <opencv2/objdetect.hpp>
|
2016-09-14 17:16:10 +08:00
|
|
|
|
2016-04-08 21:30:56 +08:00
|
|
|
#include "calibCommon.hpp"
|
|
|
|
#include "calibController.hpp"
|
|
|
|
|
|
|
|
namespace calib
|
|
|
|
{
|
|
|
|
class FrameProcessor
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~FrameProcessor();
|
|
|
|
virtual cv::Mat processFrame(const cv::Mat& frame) = 0;
|
|
|
|
virtual bool isProcessed() const = 0;
|
|
|
|
virtual void resetState() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CalibProcessor : public FrameProcessor
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
cv::Ptr<calibrationData> mCalibData;
|
|
|
|
TemplateType mBoardType;
|
2023-02-22 05:02:02 +08:00
|
|
|
cv::Size mBoardSizeUnits;
|
|
|
|
cv::Size mBoardSizeInnerCorners;
|
2016-04-08 21:30:56 +08:00
|
|
|
std::vector<cv::Point2f> mTemplateLocations;
|
|
|
|
std::vector<cv::Point2f> mCurrentImagePoints;
|
|
|
|
cv::Mat mCurrentCharucoCorners;
|
|
|
|
cv::Mat mCurrentCharucoIds;
|
|
|
|
|
|
|
|
cv::Ptr<cv::SimpleBlobDetector> mBlobDetectorPtr;
|
Merge pull request #22368 from AleksandrPanov:move_contrib_aruco_to_main_objdetect
Megre together with https://github.com/opencv/opencv_contrib/pull/3325
1. Move aruco_detector, aruco_board, aruco_dictionary, aruco_utils to objdetect
1.1 add virtual Board::draw(), virtual ~Board()
1.2 move `testCharucoCornersCollinear` to Board classes (and rename to `checkCharucoCornersCollinear`)
1.3 add wrappers to keep the old api working
3. Reduce inludes
4. Fix java tests (add objdetect import)
5. Refactoring
### Pull Request Readiness Checklist
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
```
**WIP**
force_builders=linux,win64,docs,Linux x64 Debug,Custom
Xbuild_contrib:Docs=OFF
build_image:Custom=ubuntu:22.04
build_worker:Custom=linux-1
```
2022-12-16 17:28:47 +08:00
|
|
|
cv::aruco::Dictionary mArucoDictionary;
|
2016-04-08 21:30:56 +08:00
|
|
|
cv::Ptr<cv::aruco::CharucoBoard> mCharucoBoard;
|
Merge pull request #22986 from AleksandrPanov:move_contrib_charuco_to_main_objdetect
merge with https://github.com/opencv/opencv_contrib/pull/3394
move Charuco API from contrib to main repo:
- add CharucoDetector:
```
CharucoDetector::detectBoard(InputArray image, InputOutputArrayOfArrays markerCorners, InputOutputArray markerIds,
OutputArray charucoCorners, OutputArray charucoIds) const // detect charucoCorners and/or markerCorners
CharucoDetector::detectDiamonds(InputArray image, InputOutputArrayOfArrays _markerCorners,
InputOutputArrayOfArrays _markerIds, OutputArrayOfArrays _diamondCorners,
OutputArray _diamondIds) const
```
- add `matchImagePoints()` for `CharucoBoard`
- remove contrib aruco dependencies from interactive-calibration tool
- move almost all aruco tests to objdetect
### Pull Request Readiness Checklist
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
2022-12-28 22:28:59 +08:00
|
|
|
cv::Ptr<cv::aruco::CharucoDetector> detector;
|
2016-04-08 21:30:56 +08:00
|
|
|
|
|
|
|
int mNeededFramesNum;
|
|
|
|
unsigned mDelayBetweenCaptures;
|
|
|
|
int mCapuredFrames;
|
|
|
|
double mMaxTemplateOffset;
|
|
|
|
float mSquareSize;
|
|
|
|
float mTemplDist;
|
2022-06-08 18:59:55 +08:00
|
|
|
bool mSaveFrames;
|
2022-07-01 04:31:52 +08:00
|
|
|
float mZoom;
|
2016-04-08 21:30:56 +08:00
|
|
|
|
|
|
|
bool detectAndParseChessboard(const cv::Mat& frame);
|
|
|
|
bool detectAndParseChAruco(const cv::Mat& frame);
|
2022-06-22 20:04:46 +08:00
|
|
|
bool detectAndParseCircles(const cv::Mat& frame);
|
2016-04-08 21:30:56 +08:00
|
|
|
bool detectAndParseACircles(const cv::Mat& frame);
|
|
|
|
bool detectAndParseDualACircles(const cv::Mat& frame);
|
|
|
|
void saveFrameData();
|
|
|
|
void showCaptureMessage(const cv::Mat &frame, const std::string& message);
|
|
|
|
bool checkLastFrame();
|
|
|
|
|
|
|
|
public:
|
|
|
|
CalibProcessor(cv::Ptr<calibrationData> data, captureParameters& capParams);
|
2018-03-20 20:53:57 +08:00
|
|
|
virtual cv::Mat processFrame(const cv::Mat& frame) CV_OVERRIDE;
|
|
|
|
virtual bool isProcessed() const CV_OVERRIDE;
|
|
|
|
virtual void resetState() CV_OVERRIDE;
|
|
|
|
~CalibProcessor() CV_OVERRIDE;
|
2016-04-08 21:30:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum visualisationMode {Grid, Window};
|
|
|
|
|
|
|
|
class ShowProcessor : public FrameProcessor
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
cv::Ptr<calibrationData> mCalibdata;
|
|
|
|
cv::Ptr<calibController> mController;
|
|
|
|
TemplateType mBoardType;
|
|
|
|
visualisationMode mVisMode;
|
|
|
|
bool mNeedUndistort;
|
|
|
|
double mGridViewScale;
|
|
|
|
double mTextSize;
|
|
|
|
|
|
|
|
void drawBoard(cv::Mat& img, cv::InputArray points);
|
|
|
|
void drawGridPoints(const cv::Mat& frame);
|
|
|
|
public:
|
|
|
|
ShowProcessor(cv::Ptr<calibrationData> data, cv::Ptr<calibController> controller, TemplateType board);
|
2018-03-20 20:53:57 +08:00
|
|
|
virtual cv::Mat processFrame(const cv::Mat& frame) CV_OVERRIDE;
|
|
|
|
virtual bool isProcessed() const CV_OVERRIDE;
|
|
|
|
virtual void resetState() CV_OVERRIDE;
|
2016-04-08 21:30:56 +08:00
|
|
|
|
|
|
|
void setVisualizationMode(visualisationMode mode);
|
|
|
|
void switchVisualizationMode();
|
|
|
|
void clearBoardsView();
|
|
|
|
void updateBoardsView();
|
|
|
|
|
|
|
|
void switchUndistort();
|
|
|
|
void setUndistort(bool isEnabled);
|
2018-03-20 20:53:57 +08:00
|
|
|
~ShowProcessor() CV_OVERRIDE;
|
2016-04-08 21:30:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|