Comments (1)
This is easily done with cv::findChessboardCorners()
and cv::drawChessboardCorners()
from calib3d. The detectAndParseChessboard()
routine in opencv_interactive-calibration does this already - simply as a wrapper over those two functions - and can be used verbatim. In addition, the output of the wrapper can be used to determine if you have a parse-able image of the chessboard in both channels before making them candidates for saving, increasing the quality of input data for the subsequent calibration stages.
direct patch as a starting point:
index 5279fee..fefac40 100644
--- read_images.cpp
+++ read_images.cpp
@@ -1,3 +1,4 @@
+#include <opencv2/calib3d.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
@@ -9,6 +10,25 @@ using namespace std;
using namespace cv;
int x = 0;
+Size mBoardSize = Size(7, 10);
+std::vector<cv::Point2f> mCurrentImagePoints;
+std::vector<cv::Point2f> mTemplateLocations;
+
+bool detectAndParseChessboard(const cv::Mat &frame)
+{
+ int chessBoardFlags = cv::CALIB_CB_ADAPTIVE_THRESH | cv::CALIB_CB_NORMALIZE_IMAGE | cv::CALIB_CB_FAST_CHECK;
+ bool isTemplateFound = cv::findChessboardCorners(frame, mBoardSize, mCurrentImagePoints, chessBoardFlags);
+
+ if (isTemplateFound) {
+ cv::Mat viewGray;
+ cv::cvtColor(frame, viewGray, cv::COLOR_BGR2GRAY);
+ cv::cornerSubPix(viewGray, mCurrentImagePoints, cv::Size(11,11),
+ cv::Size(-1,-1), cv::TermCriteria( cv::TermCriteria::EPS+cv::TermCriteria::COUNT, 30, 0.1 ));
+ cv::drawChessboardCorners(frame, mBoardSize, cv::Mat(mCurrentImagePoints), isTemplateFound);
+ mTemplateLocations.insert(mTemplateLocations.begin(), mCurrentImagePoints[0]);
+ }
+ return isTemplateFound;
+}
int main(int argc, char const *argv[])
{
@@ -35,8 +55,12 @@ int main(int argc, char const *argv[])
while (1) {
cap1 >> img1;
cap2 >> img2;
- resize(img1, img_res1, Size(im_width, im_height));
- resize(img2, img_res2, Size(im_width, im_height));
+ img_res1 = img1.clone();
+ img_res2 = img2.clone();
+ detectAndParseChessboard(img_res1);
+ detectAndParseChessboard(img_res2);
+ resize(img_res1, img_res1, Size(im_width, im_height));
+ resize(img_res2, img_res2, Size(im_width, im_height));
imshow("IMG1", img_res1);
imshow("IMG2", img_res2);
if (waitKey(30) > 0) {
from stereo-calibration.
Related Issues (16)
- popt.h not available in Windows HOT 3
- do not use popt HOT 2
- Documentation not clear
- error: (-215:Assertion failed) VScn::contains(scn) && VDcn::contains(dcn) && VDepth::contains(depth) in function 'CvtHelper' HOT 1
- Any image pair for testing? HOT 1
- Error converting BGR to GRAY HOT 2
- Question about vectors in calib_stereo.cpp
- How to use kinect v2 with this code? HOT 3
- Error when using calibration HOT 2
- calib-stereo.cpp: Use Mat for T
- Implement stereo calibration using AprilTags HOT 2
- GUI
- Stereo calibration using user-specified correspondences
- Visualizing camera and checkerboard poses
- Statistical analysis of calibration HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stereo-calibration.