2016-11-14 03:43:30 -0600
| commented answer | Matrix rotation error and how pull out a single element I create Mat Thx = Mat::zeros(1, 1, CV_64F);
Thx.at<double>(0, 0) = (atan2(R(3), R(0))) * (180 / M_PI)
And error Error 1 error C2664: 'cv::Mat cv::Mat::operator ()(cv::Range,cv::Range) const' : cannot convert argument 1 from 'int' to 'const cv::Range *' |
2016-11-10 04:50:44 -0600
| commented question | Matrix rotation error and how pull out a single element *Professor at the University gave me this formula *I know that it is a vector of rotation, according to Professor I do with this design, which is why it needs rotation matrix. *The main idea is that I received the position and orientation of the marker relative to the camera. I needs this to the vision system robot. To be able later to steer the robot at reasonably "When X> 10 move to the left of 5, etc." when the camera will centered over the marker the robot takes the object |
2016-11-10 04:37:04 -0600
| asked a question | Matrix rotation error and how pull out a single element Hi,
I have problem with matrix rotation. I am using the module Aruco to receive marker position. Then I use the function Rodrigues () to receive a rotation matrix. I would like to pull out of the matrix as a single element needs to calculate the orientation of the marker. But all the time I error.
The following code: cv::Mat 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();
Mat R = Mat::zeros(3, 3, CV_64F);
Rodrigues(rvecs, R);
Here is the formula: Mat Thz = (atan2 (R (3), R (0))) * (180 / M_PI)
But the problem is in the variables. When I'm use R.at <double> (1, 1) displays a single element matrix. For example, when I give Mat thz = atan2 (R.at <double> (1, 1), R.at <double> (1, 2)); , displays error C2440: 'initializing': can not convert from 'double' this' cv :: Mat How do I convert the matrix R so I can use them with designs and functions atan2? |
2016-10-26 07:49:23 -0600
| received badge | ● Editor
(source)
|
2016-10-26 07:48:34 -0600
| asked a question | Aruco matrix view Hello, I want to receive position from Aruco of marker. The following code, I draw the axes on the marker and very good catches it. How do I read the value of the matrix from the camera position of marker? Are needed axes x, y, z and the rotation axis. Does anyone have any idea? #include <opencv2/highgui.hpp>
#include <opencv2\aruco.hpp>
#include <iostream>
using namespace std;
using namespace cv;
static bool readCameraParameters(string filename, Mat &camMatrix, Mat &distCoeffs) {
FileStorage fs(filename, FileStorage::READ);
if (!fs.isOpened())
return false;
fs["camera_matrix"] >> camMatrix;
fs["distortion_coefficients"] >> distCoeffs;
return true;
}
/**
*/
static bool readDetectorParameters(string filename, Ptr<aruco::DetectorParameters> ¶ms) {
FileStorage fs(filename, FileStorage::READ);
if (!fs.isOpened())
return false;
fs["adaptiveThreshWinSizeMin"] >> params->adaptiveThreshWinSizeMin;
fs["adaptiveThreshWinSizeMax"] >> params->adaptiveThreshWinSizeMax;
fs["adaptiveThreshWinSizeStep"] >> params->adaptiveThreshWinSizeStep;
fs["adaptiveThreshConstant"] >> params->adaptiveThreshConstant;
fs["minMarkerPerimeterRate"] >> params->minMarkerPerimeterRate;
fs["maxMarkerPerimeterRate"] >> params->maxMarkerPerimeterRate;
fs["polygonalApproxAccuracyRate"] >> params->polygonalApproxAccuracyRate;
fs["minCornerDistanceRate"] >> params->minCornerDistanceRate;
fs["minDistanceToBorder"] >> params->minDistanceToBorder;
fs["minMarkerDistanceRate"] >> params->minMarkerDistanceRate;
fs["doCornerRefinement"] >> params->doCornerRefinement;
fs["cornerRefinementWinSize"] >> params->cornerRefinementWinSize;
fs["cornerRefinementMaxIterations"] >> params->cornerRefinementMaxIterations;
fs["cornerRefinementMinAccuracy"] >> params->cornerRefinementMinAccuracy;
fs["markerBorderBits"] >> params->markerBorderBits;
fs["perspectiveRemovePixelPerCell"] >> params->perspectiveRemovePixelPerCell;
fs["perspectiveRemoveIgnoredMarginPerCell"] >> params->perspectiveRemoveIgnoredMarginPerCell;
fs["maxErroneousBitsInBorderRate"] >> params->maxErroneousBitsInBorderRate;
fs["minOtsuStdDev"] >> params->minOtsuStdDev;
fs["errorCorrectionRate"] >> params->errorCorrectionRate;
return true;
}
/**
*/
int main(int argc, char *argv[]) {
int dictionaryId = 0;
bool showRejected = false;
bool estimatePose = true;
float markerLength = 200;
Ptr<aruco::DetectorParameters> detectorParams = aruco::DetectorParameters::create();
detectorParams->doCornerRefinement = true; // do corner refinement in markers
Ptr<aruco::Dictionary> dictionary =
aruco::getPredefinedDictionary(aruco::PREDEFINED_DICTIONARY_NAME(dictionaryId));
Mat camMatrix, distCoeffs;
if (estimatePose) {
bool readOk = readCameraParameters("kalibracja", camMatrix, distCoeffs);
if (!readOk) {
cerr << "Invalid camera file" << endl;
return 0;
}
}
VideoCapture inputVideo;
inputVideo.open(0);
double totalTime = 0;
int totalIterations = 0;
while (inputVideo.grab()) {
Mat image, imageCopy;
inputVideo.retrieve(image);
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;
}
if (totalIterations % 30 == 0) {
cout << "Detection Time = " << currentTime * 1000 << " ms "
<< "(Mean = " << 1000 * totalTime / double(totalIterations) << " ms)" << endl;
}
// draw results
image.copyTo(imageCopy);
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)waitKey(100);
if (key == 27) break;
}
system("pause");
return 0;
}
|
2016-10-13 02:33:36 -0600
| commented question | OpenCv2.4.13 + Aruco So unfortunately do not help? |
2016-10-13 02:28:22 -0600
| commented question | OpenCv2.4.13 + Aruco |
2016-10-13 02:23:36 -0600
| commented question | OpenCv2.4.13 + Aruco That's why I wanted to compile aruco 2.0.13, because there are those files |
2016-10-13 02:19:40 -0600
| commented question | OpenCv2.4.13 + Aruco opencv_contrib/modules i compile with openCV, and it's a aruco and work in there but not include aruco.h, cvdrawingutils.h, only aruco.hpp, charuco and dictionary. |
2016-10-13 02:01:33 -0600
| commented question | OpenCv2.4.13 + Aruco I get opencv master, and again I put link to Aruco in "Source code", and link to build folder. Then CMake Error at CMakeLists.txt:51 (FIND_PACKAGE):
By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "OpenCV", but
CMake did not find one. Could not find a package configuration file provided by "OpenCV" with any
of the following names: OpenCVConfig.cmake
opencv-config.cmake
So I link to openCV master 3.1 in OPENCV_DIR and again compiel but:
Found OpenCV Windows Pack but it has no binaries compatible with your configuration. I must complie OpenCV-master and add Aruco in opencv_contrib and compile or what? |
2016-10-12 17:32:54 -0600
| asked a question | OpenCv2.4.13 + Aruco Hello,
I have problem to compile OpenCv with Aruco 2.0.13, i'ts my first time to use Cmake.! So I put link to Aruco in "Source code", and link to build folder. Configure to VS 2013 WIN64 with Specify native compilers, and I have error. I attach in picture.
Please explain to me in a simple way how to compile aruco. I have Windows 10, VS 2013. I tried to use this guide: Tutorial I was able to compile everything correctly, I added to the VS 2013 and operates aruco but the library does not have files there aruco.h, cvdrawingutils.h. Only charuco and dictionary Or how to add these files to the files that I was able to compile from the guide. |