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

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>
            免费av成人在线| 国内精品久久久久影院 日本资源| 欧美风情在线| 欧美日韩综合| 欧美日韩精品免费观看视一区二区| 久久这里有精品视频| 久久免费观看视频| 免费亚洲一区| 国产精品成人aaaaa网站| 精品96久久久久久中文字幕无| 午夜免费电影一区在线观看| 韩国av一区| 一区在线免费| 日韩视频二区| 午夜日韩电影| 久久久久久久999| 久久综合网络一区二区| 欧美高清日韩| 亚洲小视频在线| 久久国产精品一区二区三区| 美女视频网站黄色亚洲| 欧美日韩一区二区免费在线观看| 欧美日韩在线视频首页| 国语自产精品视频在线看抢先版结局| 亚洲精品视频免费观看| 亚洲青色在线| 国内精品一区二区三区| 99在线精品免费视频九九视| 亚洲一区二区三区在线| 亚洲国产精品ⅴa在线观看| 亚洲视频精选在线| 欧美伦理91| 亚洲国产综合91精品麻豆| 久久国产精品色婷婷| 亚洲日本黄色| 欧美高清视频一区二区三区在线观看| 国产视频在线一区二区| 亚洲欧美日韩精品综合在线观看| 亚洲国产精品欧美一二99| 亚洲免费在线| 中日韩视频在线观看| 亚洲国产精品久久91精品| 久久精彩视频| 国精品一区二区三区| 久久精品一区二区| 欧美中文字幕| 91久久精品国产91久久性色| 久久疯狂做爰流白浆xx| 欧美一区在线看| 在线精品视频一区二区| 欧美国内亚洲| 国产精品久久久久三级| 久久久久国产精品一区| 噜噜噜噜噜久久久久久91| 1000精品久久久久久久久| 亚洲经典在线看| 国产精品视频大全| 亚洲电影激情视频网站| 国产精品久久久久久超碰| 欧美在现视频| 欧美精品久久99| 久久精品免费看| 欧美午夜宅男影院在线观看| 久久久成人精品| 欧美色123| 亚洲人成在线观看一区二区| 国产日韩欧美一区二区| 亚洲国产精品www| 在线观看日韩www视频免费| 亚洲精品国产精品国产自| 激情视频一区二区| 欧美亚洲免费| 久久国内精品视频| 国产乱码精品一区二区三区忘忧草| 欧美成人精品三级在线观看| 亚洲国产三级网| 亚洲国产精品va| 另类综合日韩欧美亚洲| 久久九九国产精品| 韩国一区二区三区在线观看| 午夜老司机精品| 久久久另类综合| 亚洲国产成人精品女人久久久| 欧美一区二区三区四区夜夜大片 | 欧美伊人久久| 国产精品久久久久久久久免费樱桃| 欧美高清自拍一区| 在线一区二区视频| 国产一级一区二区| 欧美一区视频| 91久久国产自产拍夜夜嗨| 日韩亚洲欧美高清| 国产精品视频成人| 久久五月天婷婷| 亚洲视频一区在线| 嫩草国产精品入口| 亚洲影视中文字幕| 亚洲国产一区二区精品专区| 欧美天天在线| 欧美极品在线观看| 久久精品99久久香蕉国产色戒| 欧美国产日本在线| 久久天天狠狠| 亚洲小说春色综合另类电影| 亚洲国产日韩欧美| 国产视频久久| 国产精品私房写真福利视频| 欧美精品日韩三级| 美女91精品| 亚洲精品久久久久中文字幕欢迎你 | 国产日韩欧美精品| 欧美片第一页| 欧美国产日韩视频| 久久亚洲春色中文字幕久久久| 午夜精品久久久久久久久 | 久久久久99| 欧美中文在线观看| 久久岛国电影| 嫩模写真一区二区三区三州| 欧美成人免费全部| 亚洲第一区色| 亚洲精品国精品久久99热一| 亚洲国产精品传媒在线观看| 亚洲国产欧美另类丝袜| 日韩一级片网址| 亚洲欧美精品suv| 欧美大片91| 国产乱肥老妇国产一区二 | 91久久久一线二线三线品牌| 亚洲日本aⅴ片在线观看香蕉| 亚洲欧洲日产国码二区| 亚洲图片激情小说| 麻豆国产精品777777在线| 亚洲国产欧美在线人成| 亚洲色图自拍| 久久综合久久综合这里只有精品| 欧美电影免费观看高清| 国产精品夜夜夜| 亚洲精品一区久久久久久| 欧美自拍偷拍午夜视频| 在线精品国精品国产尤物884a| 亚洲国产一区二区视频| 欧美一区二区私人影院日本| 欧美国产第二页| 久久国产精品网站| 国产免费亚洲高清| 亚洲天堂网站在线观看视频| 欧美成年人视频| 久久精品官网| 国产一区二区三区直播精品电影| 一区二区冒白浆视频| 亚洲国产精品成人综合色在线婷婷| 亚洲一区一卡| 国产亚洲精品综合一区91| 午夜宅男欧美| 香蕉久久精品日日躁夜夜躁| 国产精品久久久久久久久久免费| 一本色道久久加勒比精品| 亚洲激情在线播放| 欧美伦理91| 亚洲欧美在线视频观看| 亚洲伊人一本大道中文字幕| 国产精品入口日韩视频大尺度| 午夜在线一区二区| 久久精品一本| 亚洲人成高清| 亚洲一区二区黄色| 狠狠色伊人亚洲综合网站色| 免费亚洲一区二区| 欧美性猛交视频| 久久一区亚洲| 欧美日韩精品免费观看视频完整| 亚洲视频一区二区| 欧美亚洲综合另类| 91久久精品国产91久久性色| 99热在这里有精品免费| 国产一区二区成人| 亚洲精品国精品久久99热一| 欧美三级资源在线| 亚洲国产成人tv| 免费日韩av片| 亚洲激情六月丁香| 亚洲国产精品电影在线观看| 国产伦精品一区二区三区高清 | 亚洲国产成人精品视频| 国产精品家庭影院| 亚洲三级免费| 亚洲大黄网站| 久久综合狠狠综合久久综合88| 亚洲综合国产| 欧美日韩免费一区| 亚洲欧洲在线免费| 亚洲国产一区二区三区青草影视| 午夜精品美女久久久久av福利| 日韩一级在线观看| 欧美精品日韩一区| 亚洲人成亚洲人成在线观看图片 | 欧美午夜精品久久久| 欧美电影免费观看高清| 国内精品久久久久久久影视蜜臀|