From e1c1e9c65ad1a0bf17c2b55be4640c3a417fb010 Mon Sep 17 00:00:00 2001 From: SpidersBro Date: Thu, 14 Nov 2013 11:34:06 +0100 Subject: [PATCH 1/4] Test Added the word "test" in comment section --- src/CameraGeometricCalibration.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CameraGeometricCalibration.cpp b/src/CameraGeometricCalibration.cpp index 3d00fc3..198fd9b 100644 --- a/src/CameraGeometricCalibration.cpp +++ b/src/CameraGeometricCalibration.cpp @@ -3,6 +3,7 @@ * * Created on: 12 nov. 2013 * Author: Jetze en Barend + * Test */ #include From 13fbc63ae75b30e6fa1ccf8269d1809410d5e699 Mon Sep 17 00:00:00 2001 From: SpidersBro Date: Thu, 14 Nov 2013 13:35:14 +0100 Subject: [PATCH 2/4] Draw rectangle in center, new code Entirely new code, draws a filled 100 x 100 white rectangle in the center of an image. --- src/CameraGeometricCalibration.cpp | 72 +++++++++++++++--------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/src/CameraGeometricCalibration.cpp b/src/CameraGeometricCalibration.cpp index 198fd9b..e84ccb7 100644 --- a/src/CameraGeometricCalibration.cpp +++ b/src/CameraGeometricCalibration.cpp @@ -1,43 +1,43 @@ -/* - * CameraGeometricCalibration.cpp - * - * Created on: 12 nov. 2013 - * Author: Jetze en Barend - * Test - */ +// Draws a white square in the center of a picture. + +#include "opencv2/core/core.hpp" +#include "opencv2/imgproc/imgproc.hpp" +#include "opencv2/highgui/highgui.hpp" -#include -#include -#include -#include #include -using namespace cv; -using namespace std; +#include -// Displays a supplied image -int main(int argc, const char** argv) { - VideoCapture camera; - Mat webcamImage; - camera.open(0); - if (!camera.isOpened()) { - cerr << "ERROR: Could not access the camera or video!" << endl; - exit(1); - } +using namespace cv; +using namespace std; - namedWindow("test", CV_WINDOW_AUTOSIZE); - while (true) { - camera >> webcamImage; - if (webcamImage.empty()) { - cerr << "ERROR: Couldn't grab a camera frame." << endl; - exit(1); - } - //rotate it on the x axis - flip(webcamImage, webcamImage, 1); - imshow("test", webcamImage); - if (27 == waitKey(33)) - break; - } - return 0; +int main() +{ + // Name path for image here + String path = "/Users/barendpoot/workspace/opencvtest/opencvtest/pic6.png"; + + Mat image; + image = imread(path, CV_LOAD_IMAGE_COLOR); // Read the file + + if(! image.data ) // Check for invalid input + { + cout << "Could not open or find the image" << endl ; + return -1; + } + + // Get Height and Width from image + Size s = image.size(); + int imgHeight = s.height; + int imgWidth = s.width; + + //Draw filled rectangle in center of image + rectangle(image,cvPoint((imgWidth/2-50),imgHeight/2-50), cvPoint((imgWidth/2+50), imgHeight/2+50),CV_RGB(255,255,255),1,8); + + namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display. + imshow( "Display window", image ); // Show our image inside it. + + waitKey(0); // Wait for a keystroke in the window + return 0; + } From 9faee5d8d71ad7cea533a2736d78d9015ceb1290 Mon Sep 17 00:00:00 2001 From: SpidersBro Date: Sat, 16 Nov 2013 15:58:35 +0100 Subject: [PATCH 3/4] takeSamples methode Aanzet take samples. --- src/CameraGeometricCalibration.cpp | 94 +++++++++++++++++++----------- 1 file changed, 61 insertions(+), 33 deletions(-) diff --git a/src/CameraGeometricCalibration.cpp b/src/CameraGeometricCalibration.cpp index e84ccb7..a7f9535 100644 --- a/src/CameraGeometricCalibration.cpp +++ b/src/CameraGeometricCalibration.cpp @@ -1,43 +1,71 @@ -// Draws a white square in the center of a picture. - -#include "opencv2/core/core.hpp" -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/highgui/highgui.hpp" +/* + * CameraGeometricCalibration.cpp + * + * Created on: 12 nov. 2013 + * Author: Jetze en Barend + */ +#include +#include +#include +#include #include -#include - - using namespace cv; using namespace std; -int main() -{ - // Name path for image here - String path = "/Users/barendpoot/workspace/opencvtest/opencvtest/pic6.png"; - - Mat image; - image = imread(path, CV_LOAD_IMAGE_COLOR); // Read the file - - if(! image.data ) // Check for invalid input - { - cout << "Could not open or find the image" << endl ; - return -1; - } +// Displays a supplied image +int main(int argc, const char** argv) { - // Get Height and Width from image - Size s = image.size(); - int imgHeight = s.height; - int imgWidth = s.width; + VideoCapture camera; + Mat webcamImage; + camera.open(0); + if (!camera.isOpened()) { + cerr << "ERROR: Could not access the camera or video!" << endl; + exit(1); + } - //Draw filled rectangle in center of image - rectangle(image,cvPoint((imgWidth/2-50),imgHeight/2-50), cvPoint((imgWidth/2+50), imgHeight/2+50),CV_RGB(255,255,255),1,8); - - namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display. - imshow( "Display window", image ); // Show our image inside it. - - waitKey(0); // Wait for a keystroke in the window - return 0; + int imgCounter =0; + namedWindow("test", CV_WINDOW_AUTOSIZE); + while (true) { + camera >> webcamImage; + if (webcamImage.empty()) { + cerr << "ERROR: Couldn't grab a camera frame." << endl; + exit(1); + } + + // Vectors + vector pointBuf; + vector > imagePoints; + + + + // set boardSize + Size boardSize; + boardSize.width = 9; + boardSize.height = 6; + + //rotate it on the x axis + flip(webcamImage, webcamImage, 1); + imshow("test", webcamImage); + + // Find a chessboard pattern on webcamfeed with size boardSize. + bool found; + found = findChessboardCorners( webcamImage, boardSize, pointBuf, + CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FAST_CHECK | CV_CALIB_CB_NORMALIZE_IMAGE); + + if(found && imgCounter <25) + { + imagePoints.push_back(pointBuf); + imgCounter++; + cout << pointBuf << endl; + + } + + + if (27 == waitKey(33)) + break; + } + return 0; } From 8fc68a11fb92119e49db86fbd5626058fc147fce Mon Sep 17 00:00:00 2001 From: SpidersBro Date: Sat, 16 Nov 2013 18:09:56 +0100 Subject: [PATCH 4/4] Commented function Added start of takeSamples function in comment block --- src/CameraGeometricCalibration.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/CameraGeometricCalibration.cpp b/src/CameraGeometricCalibration.cpp index a7f9535..fc9c36b 100644 --- a/src/CameraGeometricCalibration.cpp +++ b/src/CameraGeometricCalibration.cpp @@ -10,9 +10,15 @@ #include #include #include +#include + using namespace cv; using namespace std; +bool takeSamples(Mat webcamImage,Size boardSize, vector& imagePoints, Vector& pointBuf); + + + // Displays a supplied image int main(int argc, const char** argv) { @@ -59,6 +65,7 @@ int main(int argc, const char** argv) { imagePoints.push_back(pointBuf); imgCounter++; cout << pointBuf << endl; + } @@ -69,3 +76,11 @@ int main(int argc, const char** argv) { return 0; } +//bool takeSamples(Mat webcamImage,Size boardSize, vector& imagePoints, Vector& pointBuf) +//{ + +// findChessboardCorners(webcamImage, boardSize, pointBuf); +// imagePoints.push_back(pointBuf); +// usleep(1); + +//}