Hey guys, so im trying to use aruco detect_markers. It works normally, but the image is only 640x480 (which is bad for a 720p camera) I tried to raise it to 720p with (cv::CAP_PROP_FRAME_WIDTH,1280); and height, but it lowers the fps down to about 2fps. I have no clue whats wrong
cv::VideoCapture inputVideo;
int waitTime;
if(!video.empty()) {
inputVideo.open(video);
waitTime = 0;
} else {
inputVideo.open(camId);
waitTime = 1;
}
double totalTime = 0;
int totalIterations = 0;
while(inputVideo.grab()) {
inputVideo.set(cv::CAP_PROP_FRAME_WIDTH,1280);
inputVideo.set(cv::CAP_PROP_FRAME_HEIGHT,720);
cv::Mat image, imageCopy;
inputVideo.retrieve(image);
image.copyTo(imageCopy);
double tick = (double)getTickCount();
vector< int > ids;
vector< vector< Point2f > > corners, rejected;
vector< Vec3d > rvecs, tvecs;
// detect markers and estimate pose
aruco::detectMarkers(image, dictionary, corners, ids, detectorParams, rejected);
if(estimatePose && ids.size() > 0)
aruco::estimatePoseSingleMarkers(corners, markerLength, camMatrix, distCoeffs, rvecs,
tvecs);
double currentTime = ((double)getTickCount() - tick) / getTickFrequency();
totalTime += currentTime;
totalIterations++;
if(totalIterations % 30 == 0) {
cout << "Detection Time = " << currentTime * 1000 << " ms "
<< "(Mean = " << 1000 * totalTime / double(totalIterations) << " ms)" << endl;
}
// draw results
if(ids.size() > 0) {
aruco::drawDetectedMarkers(imageCopy, corners, ids);
if(estimatePose) {
for(unsigned int i = 0; i < ids.size(); i++)
aruco::drawAxis(imageCopy, camMatrix, distCoeffs, rvecs[i], tvecs[i],
markerLength * 0.5f);
}
}
if(showRejected && rejected.size() > 0)
aruco::drawDetectedMarkers(imageCopy, rejected, noArray(), Scalar(100, 0, 255));
imshow("out", imageCopy);
char key = (char)cv::waitKey(waitTime);
if (key == 27)
break;
}
inputVideo.release();
return 0;
}