青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

How to tranform 2D image coordinates to 3D world coordinated with Z = 0?

http://answers.opencv.org/question/150451/how-to-tranform-2d-image-coordinates-to-3d-world-coordinated-with-z-0/
https://github.com/opencv/opencv/issues/8762

Hi everyone, I currently working on my project which involves vehicle detection and tracking and estimating and optimizing a cuboid around the vehicle. For that I am taking the center of the detected vehicle and I need to find the 3D world coodinate of the point and then estimate the world coordinates of the edges of the cuboid and the project it back to the image to display it.
So, now I am new to computer vision and OpenCV, but in my knowledge, I just need 4 points on the image and need to know the world coordinates of those 4 points and use solvePNP in OpenCV to get the rotation and translation vectors (I already have the camera matrix and distortion coefficients). Then, I need to use Rodrigues to transform the rotation vector into a rotation matrix and then concatenate it with the translation vector to get my extrinsic matrix and then multiply the extrinsic matrix with the camera matrix to get my projection matrix. Since my z coordinate is zero, so I need to take off the third column from the projection matrix which gives the homography matrix for converting the 2D image points to 3D world points. Now, I find the inverse of the homography matrix which gives me the homography between the 3D world points to 2D image points. After that I multiply the image points [x, y, 1]t with the inverse homography matrix to get [wX, wY, w]t and the divide the entire vector by the scalar w to get [X, Y, 1] which gives me the X and Y values of the world coordinates.
My code is like this:
image_points.push_back(Point2d(275, 204));
image_points.push_back(Point2d(331, 204));
image_points.push_back(Point2d(331, 308));
image_points.push_back(Point2d(275, 308));
cout << "Image Points: " << image_points << endl << endl;
world_points.push_back(Point3d(0.0, 0.0, 0.0));
world_points.push_back(Point3d(1.775, 0.0, 0.0));
world_points.push_back(Point3d(1.775, 4.620, 0.0));
world_points.push_back(Point3d(0.0, 4.620, 0.0));
cout << "World Points: " << world_points << endl << endl;
solvePnP(world_points, image_points, cameraMatrix, distCoeffs, rotationVector, translationVector);
cout << "Rotation Vector: " << endl << rotationVector << endl << endl;
cout << "Translation Vector: " << endl << translationVector << endl << endl;
Rodrigues(rotationVector, rotationMatrix);
cout << "Rotation Matrix: " << endl << rotationMatrix << endl << endl;
hconcat(rotationMatrix, translationVector, extrinsicMatrix);
cout << "Extrinsic Matrix: " << endl << extrinsicMatrix << endl << endl;
projectionMatrix = cameraMatrix * extrinsicMatrix;
cout << "Projection Matrix: " << endl << projectionMatrix << endl << endl;
double p11 = projectionMatrix.at<double>(0, 0),
    p12 = projectionMatrix.at<double>(0, 1),
    p14 = projectionMatrix.at<double>(0, 3),
    p21 = projectionMatrix.at<double>(1, 0),
    p22 = projectionMatrix.at<double>(1, 1),
    p24 = projectionMatrix.at<double>(1, 3),
    p31 = projectionMatrix.at<double>(2, 0),
    p32 = projectionMatrix.at<double>(2, 1),
    p34 = projectionMatrix.at<double>(2, 3);
homographyMatrix = (Mat_<double>(3, 3) << p11, p12, p14, p21, p22, p24, p31, p32, p34);
cout << "Homography Matrix: " << endl << homographyMatrix << endl << endl;
inverseHomographyMatrix = homographyMatrix.inv();
cout << "Inverse Homography Matrix: " << endl << inverseHomographyMatrix << endl << endl;
Mat point2D = (Mat_<double>(3, 1) << image_points[0].x, image_points[0].y, 1);
cout << "First Image ...

https://github.com/opencv/opencv/issues/8762


  • OpenCV => 3.2
  • Operating System / Platform => Windows 64 Bit
  • Compiler => Visual Studio 2015

Hi everyone, I understand that this forum is to report bugs and not to ask questions but I already posted about my problems in answers.opencv.org without any useful response. I need to resolve my problem very urgently since my final year project deadline is approaching soon.

I am currently working on my project which involves vehicle detection and tracking and estimating and optimizing a cuboid around the vehicle. For that I have accomplished detection and tracking of vehicles and I need to find the 3-D world coordinates of the image points of the edges of the bounding boxes of the vehicles and then estimate the world coordinates of the edges of the cuboid and the project it back to the image to display it.

So, I am new to computer vision and OpenCV, but in my knowledge, I just need 4 points on the image and need to know the world coordinates of those 4 points and use solvePNP in OpenCV to get the rotation and translation vectors (I already have the camera matrix and distortion coefficients). Then, I need to use Rodrigues to transform the rotation vector into a rotation matrix and then concatenate it with the translation vector to get my extrinsic matrix and then multiply the extrinsic matrix with the camera matrix to get my projection matrix. Since my z coordinate is zero, so I need to take off the third column from the projection matrix which gives the homography matrix for converting the 2D image points to 3D world points. Now, I find the inverse of the homography matrix which gives me the homography between the 3D world points to 2D image points. After that I multiply the image points [x, y, 1]t with the inverse homography matrix to get [wX, wY, w]t and the divide the entire vector by the scalar w to get [X, Y, 1] which gives me the X and Y values of the world coordinates.

My code looks like this:

#include "opencv2/opencv.hpp" #include <stdio.h> #include <iostream> #include <sstream> #include <math.h> #include <conio.h>  using namespace cv; using namespace std;  Mat cameraMatrix, distCoeffs, rotationVector, rotationMatrix, translationVector, extrinsicMatrix, projectionMatrix, homographyMatrix, inverseHomographyMatrix;   Point point; vector<Point2d> image_points; vector<Point3d> world_points;  int main() {     FileStorage fs1("intrinsics.yml", FileStorage::READ);     fs1["camera_matrix"] >> cameraMatrix;    cout << "Camera Matrix: " << cameraMatrix << endl << endl;     fs1["distortion_coefficients"] >> distCoeffs;    cout << "Distortion Coefficients: " << distCoeffs << endl << endl;          image_points.push_back(Point2d(275, 204));    image_points.push_back(Point2d(331, 204));    image_points.push_back(Point2d(331, 308));    image_points.push_back(Point2d(275, 308));     cout << "Image Points: " << image_points << endl << endl;     world_points.push_back(Point3d(0.0, 0.0, 0.0));    world_points.push_back(Point3d(1.775, 0.0, 0.0));    world_points.push_back(Point3d(1.775, 4.620, 0.0));    world_points.push_back(Point3d(0.0, 4.620, 0.0));     cout << "World Points: " << world_points << endl << endl;     solvePnP(world_points, image_points, cameraMatrix, distCoeffs, rotationVector, translationVector);    cout << "Rotation Vector: " << endl << rotationVector << endl << endl;    cout << "Translation Vector: " << endl << translationVector << endl << endl;     Rodrigues(rotationVector, rotationMatrix);    cout << "Rotation Matrix: " << endl << rotationMatrix << endl << endl;     hconcat(rotationMatrix, translationVector, extrinsicMatrix);    cout << "Extrinsic Matrix: " << endl << extrinsicMatrix << endl << endl;     projectionMatrix = cameraMatrix * extrinsicMatrix;    cout << "Projection Matrix: " << endl << projectionMatrix << endl << endl;     double p11 = projectionMatrix.at<double>(0, 0),    	p12 = projectionMatrix.at<double>(0, 1),    	p14 = projectionMatrix.at<double>(0, 3),    	p21 = projectionMatrix.at<double>(1, 0),    	p22 = projectionMatrix.at<double>(1, 1),    	p24 = projectionMatrix.at<double>(1, 3),    	p31 = projectionMatrix.at<double>(2, 0),    	p32 = projectionMatrix.at<double>(2, 1),    	p34 = projectionMatrix.at<double>(2, 3);      homographyMatrix = (Mat_<double>(3, 3) << p11, p12, p14, p21, p22, p24, p31, p32, p34);    cout << "Homography Matrix: " << endl << homographyMatrix << endl << endl;     inverseHomographyMatrix = homographyMatrix.inv();    cout << "Inverse Homography Matrix: " << endl << inverseHomographyMatrix << endl << endl;     Mat point2D = (Mat_<double>(3, 1) << image_points[0].x, image_points[0].y, 1);    cout << "First Image Point" << point2D << endl << endl;     Mat point3Dw = inverseHomographyMatrix*point2D;    cout << "Point 3D-W : " << point3Dw << endl << endl;     double w = point3Dw.at<double>(2, 0);    cout << "W: " << w << endl << endl;     Mat matPoint3D;    divide(w, point3Dw, matPoint3D);     cout << "Point 3D: " << matPoint3D << endl << endl;     _getch();    return 0; }

I have got the image coordinates of the four known world points and hard-coded it for simplification.image_points contain the image coordinates of the four points and world_points contain the world coordinates of the four points. I am considering the the first world point as the origin (0, 0, 0) in the world axis and using known distance calculating the coordinates of the other four points. Now after calculating the inverse homography matrix, I multiplied it with [image_points[0].x, image_points[0].y, 1]t which is related to the world coordinate (0, 0, 0). Then I divide the result by the third component w to get [X, Y, 1]. But after printing out the values of X and Y, it turns out they are not 0, 0 respectively. What am doing wrong?

The output of my code is like this:

Camera Matrix: [517.0036881709533, 0, 320;  0, 517.0036881709533, 212;  0, 0, 1]  Distortion Coefficients: [0.1128663679798094;  -1.487790079922432;  0;  0;  2.300571896761067]  Image Points: [275, 204;  331, 204;  331, 308;  275, 308]  World Points: [0, 0, 0;  1.775, 0, 0;  1.775, 4.62, 0;  0, 4.62, 0]  Rotation Vector: [0.661476468596541;  -0.02794460022559267;  0.01206996342819649]  Translation Vector: [-1.394495345140898;  -0.2454153722672731;  15.47126945512652]  Rotation Matrix: [0.9995533907649279, -0.02011656447351923, -0.02209848058392758;  0.002297501163799448, 0.7890323093017149, -0.6143474069013439;  0.02979497438726573, 0.6140222623910194, 0.7887261380159]  Extrinsic Matrix: [0.9995533907649279, -0.02011656447351923, -0.02209848058392758, -1.394495345140898;  0.002297501163799448, 0.7890323093017149, -0.6143474069013439, -0.2454153722672731;  0.02979497438726573, 0.6140222623910194, 0.7887261380159, 15.47126945512652]  Projection Matrix: [526.3071813531748, 186.086785938988, 240.9673682002232, 4229.846989065414;  7.504351145361707, 538.1053336219271, -150.4099339268854, 3153.028471890794;  0.02979497438726573, 0.6140222623910194, 0.7887261380159, 15.47126945512652]  Homography Matrix: [526.3071813531748, 186.086785938988, 4229.846989065414;  7.504351145361707, 538.1053336219271, 3153.028471890794;  0.02979497438726573, 0.6140222623910194, 15.47126945512652]  Inverse Homography Matrix: [0.001930136511648154, -8.512427241879318e-05, -0.5103513244724983;  -6.693679705844383e-06, 0.00242178892313387, -0.4917279870709287;  -3.451449134581896e-06, -9.595179260534558e-05, 0.08513443835773901]  First Image Point[275;  204;  1]  Point 3D-W : [0.003070864657310213;  0.0004761913292736786;  0.06461112415423849]  W: 0.0646111  Point 3D: [21.04004290792539;  135.683117651025;  1] 





posted on 2017-11-17 14:40 zmj 閱讀(700) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲自拍啪啪| 日韩一区二区精品| 9i看片成人免费高清| 国产午夜精品视频免费不卡69堂| 国产精品高潮久久| 国产精品美女久久久| 国产一区二区三区久久久久久久久| 国产视频在线观看一区二区三区 | 亚洲视频免费| 在线亚洲自拍| 久久www成人_看片免费不卡| 久久亚洲一区| 欧美日韩日日骚| 国产亚洲永久域名| 99www免费人成精品| 亚洲卡通欧美制服中文| 亚洲欧美视频一区| 亚洲免费中文字幕| 亚洲三级影院| 性欧美video另类hd性玩具| 久久一二三区| 日韩亚洲视频| 久久精品99国产精品日本| 农村妇女精品| 国产精品乱人伦一区二区| 亚洲国产日韩一区二区| 亚洲视频碰碰| 久久综合影音| 日韩特黄影片| 免费在线亚洲| 激情久久婷婷| 日韩一级在线观看| 亚洲一级片在线观看| 一区二区三区精品在线| 亚洲天堂成人| 亚洲综合999| 另类综合日韩欧美亚洲| 久久人91精品久久久久久不卡| 亚洲黄色在线观看| 欧美在线日韩| 亚洲伦理精品| 蜜桃久久精品乱码一区二区| 国产麻豆日韩欧美久久| 99成人精品| 欧美国产视频在线| 欧美影院精品一区| 国产精品一区二区三区免费观看| 日韩亚洲一区在线播放| 欧美成人中文字幕| 久久久91精品国产一区二区三区| 国产精品成人免费视频| 一区二区三区四区五区精品视频| 免费日韩视频| 免费看成人av| 久久久精品久久久久| 国产一区二区成人| 久久久久久穴| 欧美一区二区三区在| 国产日韩欧美制服另类| 欧美在线高清| 久久久久免费观看| 99精品国产福利在线观看免费 | 亚洲国产视频一区| 久久午夜电影| 久久久久五月天| 亚洲人体大胆视频| 亚洲一区中文| 在线一区日本视频| 欧美在线精品免播放器视频| 欧美午夜不卡在线观看免费 | 久久夜色精品国产欧美乱| 欧美一区二区三区在线| 欧美午夜宅男影院在线观看| 欧美成人精品| 久久久久一区二区三区| 国产一区亚洲| 欧美大香线蕉线伊人久久国产精品| 久久久蜜桃精品| 亚洲第一精品影视| 亚洲人成网站精品片在线观看| 欧美黄色一区| 亚洲男人的天堂在线观看| 亚洲主播在线播放| 国产一区二区三区奇米久涩| 老司机免费视频久久| 麻豆精品精华液| 一区二区三区四区五区精品| 亚洲永久在线观看| 尤物在线精品| 亚洲免费av观看| 国产欧美成人| 亚洲国产毛片完整版| 欧美先锋影音| 久久一本综合频道| 欧美日韩国产a| 久久久精品日韩欧美| 欧美jizzhd精品欧美巨大免费| 中文国产亚洲喷潮| 久久精品亚洲国产奇米99| 99在线精品免费视频九九视| 欧美一乱一性一交一视频| 亚洲靠逼com| 日韩一级欧洲| 99精品视频一区二区三区| 亚洲视频一区二区在线观看| 国产午夜精品理论片a级探花| 久久综合久久综合这里只有精品| 欧美日韩精品二区| 鲁鲁狠狠狠7777一区二区| 欧美日韩中文精品| 免费观看一区| 国产婷婷一区二区| 99国产精品久久久久久久久久| 国产一区日韩二区欧美三区| 99国产欧美久久久精品| 亚洲国产欧美一区| 久久成人一区二区| 亚洲精品视频啊美女在线直播| 国产亚洲精品一区二区| 欧美国产视频在线观看| 美女视频黄 久久| 韩国一区二区三区美女美女秀| 狠狠做深爱婷婷久久综合一区| 久久99伊人| 在线日韩av| 亚洲国产91| 欧美日本一区二区三区| 亚洲美女黄色片| 国产一区在线免费观看| 亚洲国产合集| 久久夜色精品国产亚洲aⅴ| 国产亚洲精品激情久久| 久久激情网站| 夜夜嗨av色一区二区不卡| 亚洲一区二区免费在线| 亚洲一区二区在线| 1024欧美极品| 欧美大尺度在线| 国产精品美女| 性xx色xx综合久久久xx| 一区二区三区导航| 国产亚洲欧洲997久久综合| 欧美一区二区大片| 国产精品专区第二| 亚洲网站在线播放| 国产精品久在线观看| 快播亚洲色图| 亚洲欧美日韩一区在线| 久久免费少妇高潮久久精品99| 欧美专区福利在线| 又紧又大又爽精品一区二区| 米奇777超碰欧美日韩亚洲| 欧美中在线观看| 久久精品导航| 亚洲香蕉网站| 免费看成人av| 免费日韩一区二区| 亚洲激情视频在线| 亚洲一区二区少妇| 亚洲欧美日韩视频二区| 夜夜嗨一区二区| 亚洲伊人网站| 亚洲一区二区免费视频| 看片网站欧美日韩| 女女同性精品视频| 久久亚洲欧美国产精品乐播| 久久亚洲欧洲| 国产亚洲一区在线播放| 国产日本欧美一区二区三区| 国产欧美精品va在线观看| 欧美亚洲视频一区二区| 免费成人黄色片| 一区二区欧美亚洲| 国产一级一区二区| 美女国产精品| 亚洲一区二区毛片| 欧美成人综合一区| 午夜精品久久久久久久久久久久久| 国产视频丨精品|在线观看| 免费观看在线综合色| 中国av一区| 欧美激情一区二区三区全黄 | 亚洲欧美日韩国产综合| 免费成人性网站| 亚洲欧美日韩国产一区二区| 亚洲第一区色| 国产亚洲激情| 国产精品第一区| 欧美激情第4页| 久久久午夜电影| 亚洲嫩草精品久久| 亚洲国产一区在线观看| 久久久久欧美精品| 亚洲视频观看| 亚洲毛片一区| 亚洲国产专区| 欧美在线中文字幕| 欧美电影打屁股sp| 亚洲欧美国产77777| 亚洲欧洲综合另类|