Untitled 1
Untitled 1
Untitled 1
hpp"
#include "opencv2\imgcodes.hpp"
#include "opencv2\imgproc.hpp"
#include "opencv2\highgui.hpp"
#include "opencv2\aruco.hpp"
#include "opencv2\calib3d.hpp"
#include <sstream>
#include <iostream>
#include <fstream>
void createArucoMakers()
{
Mat outputMarker;
Ptr<aruco ::Dictionary =
aruco::getPredefineDictionary( aruco::PREDEFINE_DICTIONARY)
vector<vector<Point3f>> worldSpaceCornerPoints(1);
createKnownBoardPosition(boardSize, squareEdgeLength,
worldSpaceCornerPoints[0]);
worldSpaceCornerPoints.resize(checkerboardImageSpacePoints.size(),
worldSpaceCornerPoints[0]);
calibrateCamera(worldSpaceCornerPoints, checkerboardImageSpacePoints,
boardSize, cameraMatrix, distanceCoefficients, rVector,tVector);
}
}
}
Mat distanceCoefficients;
vector<Mat> savedImages;
VideoCapture vid(0);
if (!vid.isOpened())
{
return;
}
nameWindow("Wedcam", CV_WINDOW_AUTOSIZE);
While (true)
{
if (!vid.read(frame))
break;
vector<Vec2f> foundPoints;
bool found = false;
switch(character)
{
case ' ':
//saving image
if (found)
{
Mat temp;
frame.copyTo(temp);
savedImages.push_back(temp);
}
break;
case 13:
//start calibration
if (savedImages.size() > 15)
{
cameraCalibration(saveImages, chessboardDimension,
calibrationSquareDimension, cameraMatrix, distanceCoefficients);
saveCameraCalibration("I loveCameraCalibration", cameraMatrix,
distanceCoefficients);
}
break;
case 27:
//exit
return 0;
break;
}
}
return 0;