首页 \ 问答 \ Opencv - 立体声系统的三角测量起源(Opencv - Triangulation origin with stereo system)

Opencv - 立体声系统的三角测量起源(Opencv - Triangulation origin with stereo system)

我正在使用立体声系统,因此我试图获得某些点的世界坐标。 我可以为每个摄像机进行特定校准,然后计算旋转矩阵和平移向量。 最后我进行了三角测量,但我不确定世界坐标的起源。

正如您在我的图中所看到的,值对应于深度值,但它们平坦时应接近400。 所以我认为原点是左相机,这就是为什么它会变化......

在此处输入图像描述

我的代码与我的投射数组和三角函数:

#C1 and C2 are the cameras matrix (left and rig)
#R_0 and T_0 are the transformation between cameras
#Coord1 and Coord2 are the correspondant coordinates of left and right respectively
P1 = np.dot(C1,np.hstack((np.identity(3),np.zeros((3,1))))) 

P2 =np.dot(C2,np.hstack(((R_0),T_0)))

for i in range(Coord1.shape[0])
    z = cv2.triangulatePoints(P1, P2, Coord1[i,],Coord2[i,])

我的相机呈现一个角度,Z轴方向(深度方向)与我的表面不正常。 我想要从基线方向的深度。 所以我必须转动我的观点?

在此处输入图像描述


I m using a stereo system and so i m trying to get world coordinates of some points. I can do it with specific calibration for each camera and then i calculate rotation matrix and translation vector. And finally i triangulate but i m not sure of the origin of the world coordinates.

As you can see on my figure, values correspond to depth value but they shoud be close of 400 as it is flat. So i suppose that the origin is the left camera that s why it variates...

enter image description here

A piece of my code with my projective arrays and triangulate function :

#C1 and C2 are the cameras matrix (left and rig)
#R_0 and T_0 are the transformation between cameras
#Coord1 and Coord2 are the correspondant coordinates of left and right respectively
P1 = np.dot(C1,np.hstack((np.identity(3),np.zeros((3,1))))) 

P2 =np.dot(C2,np.hstack(((R_0),T_0)))

for i in range(Coord1.shape[0])
    z = cv2.triangulatePoints(P1, P2, Coord1[i,],Coord2[i,])

My cameras present an angle, the Z axis direction (direction of the depth) is not normal to my surface. And i want the depth from the baseline direction. So i have to rotate my points?

enter image description here


原文:https://stackoverflow.com/questions/36017923
更新时间:2019-12-03 09:46

最满意答案

在以下代码中,points4DNorm将包含世界坐标中的3D点。 我根本没有使用矫正器,我只使用了几个2d / 3d点对,然后在这些对上解决了PnPRansac。

// rotMat1, rotMat2,tvec1 and tvec2 are retrieved from solvePnPRansac and Rodrigues
        Mat points4D;
        rotMat1.copyTo(myCam1.ProjectionMat(Rect(0, 0, 3, 3)));
        tvec1.copyTo(myCam1.ProjectionMat(Rect(3, 0, 1, 3)));

        rotMat2.copyTo(myCam2.ProjectionMat(Rect(0, 0, 3, 3)));
        tvec2.copyTo(myCam2.ProjectionMat(Rect(3, 0, 1, 3)));

        myCam1.ProjectionMat = myCam1.NewCameraMat* myCam1.ProjectionMat;
        myCam2.ProjectionMat = myCam2.NewCameraMat* myCam2.ProjectionMat;
        triangulatePoints(myCam1.ProjectionMat, myCam2.ProjectionMat, balls12d, balls22d, points4D);
        Mat points4DNorm;
      for (int k = 0; k < points4D.cols;k++)
      {
        points4D.at<float>(0, k) = (points4D.at<float>(0, k) / points4D.at<float>(3, k))/304.8;
        points4D.at<float>(1, k) = (points4D.at<float>(1, k) / points4D.at<float>(3, k)) / 304.8;
        points4D.at<float>(2, k) = (points4D.at<float>(2, k) / points4D.at<float>(3, k)) / 304.8;
        points4D.at<float>(3, k) = (points4D.at<float>(3, k) / points4D.at<float>(3, k)) / 304.8;
        std::cout << std::setprecision(9) << points4D.at<float>(0, k) << "," << points4D.at<float>(1, k) << "," << points4D.at<float>(2, k) << std::endl;
       }

In the following code, points4DNorm will contains the 3D points in world coordinates. I didn't use rectify at all, I just used a few 2d/3d point pairs and then solvePnPRansac on these pairs.

// rotMat1, rotMat2,tvec1 and tvec2 are retrieved from solvePnPRansac and Rodrigues
        Mat points4D;
        rotMat1.copyTo(myCam1.ProjectionMat(Rect(0, 0, 3, 3)));
        tvec1.copyTo(myCam1.ProjectionMat(Rect(3, 0, 1, 3)));

        rotMat2.copyTo(myCam2.ProjectionMat(Rect(0, 0, 3, 3)));
        tvec2.copyTo(myCam2.ProjectionMat(Rect(3, 0, 1, 3)));

        myCam1.ProjectionMat = myCam1.NewCameraMat* myCam1.ProjectionMat;
        myCam2.ProjectionMat = myCam2.NewCameraMat* myCam2.ProjectionMat;
        triangulatePoints(myCam1.ProjectionMat, myCam2.ProjectionMat, balls12d, balls22d, points4D);
        Mat points4DNorm;
      for (int k = 0; k < points4D.cols;k++)
      {
        points4D.at<float>(0, k) = (points4D.at<float>(0, k) / points4D.at<float>(3, k))/304.8;
        points4D.at<float>(1, k) = (points4D.at<float>(1, k) / points4D.at<float>(3, k)) / 304.8;
        points4D.at<float>(2, k) = (points4D.at<float>(2, k) / points4D.at<float>(3, k)) / 304.8;
        points4D.at<float>(3, k) = (points4D.at<float>(3, k) / points4D.at<float>(3, k)) / 304.8;
        std::cout << std::setprecision(9) << points4D.at<float>(0, k) << "," << points4D.at<float>(1, k) << "," << points4D.at<float>(2, k) << std::endl;
       }
2016-03-15

相关问答

更多

如何通过golang创建代理(how to make a proxy by golang)

我一起编写了一个GET请求的简单代理。 希望这可以帮助。 package main import ( "fmt" "io/ioutil" "log" "net/http" ) const newsTargetURL = "http://www.example.com/bd/news/home" func main() { mux := http.NewServeMux() mux.Handle("/", http.HandlerFunc(G

除了/ api / v1以外的api请求返回403“禁止”(api request other than /api/v1 return 403 “Forbidden”)

虽然我没有完成该教程,但您提出请求的服务帐户无法访问群集级信息,例如列出命名空间。 RBAC(基于角色的访问控制)将用户与Role或ClusterRole绑定在一起,授予他们不同的权限。 我的猜测是服务帐户不应该知道存在哪些其他命名空间,因此无权列出它们。 在“修复”这个方面,除了创建具有正确权限的serviceaccount / user之外,该教程还对$HOME/.kube/config存储的配置文件进行了多次引用,该文件存储了应该具有访问权限的用户的凭据。集群级资源,包括列出名称空间。 你

嵌套XML pull解析器问题,无法获取子元素(Nested XML pull parser issue ,cannot get child elements)

以下是使用数据投影的完整示例(包括您的模型): public class ReadJobs { public interface Projection extends Serializable { interface Job { @XBRead("./task") List<Task> getTasks(); @XBRead("./id") String getID();

没有实施关键字,我们可以使用接口吗?(Without Implement Keyword, Can we use interface?)

默认情况下,接口的所有变量都是public static final ,因此您可以直接使用它们 您可以通过匿名类实现接口(不使用implements关键字) public static void main(String[] args) throws Exception{ System.out.println(I.s); // accessing Interface I's variable I i = new I() { @Override public int g

字符串输入在if-else语句中不起作用(String input doesn't work in if-else statement)

字符串之间的比较需要String#equals而不是== 。 所以这: if (playAgain == "yes"){ System.out.println("Restarting game..."); start = true; } else if (playAgain == "no") { System.out.println("Quitting game."); start = false; } 必须成为这个: if (playAgain.equals(

这个powershell Foreach-Object声明有什么问题?(Whats wrong with this powershell Foreach-Object statement?)

我终于找到了答案。 我必须在括号中设置Get-Connections命令: (Get-Connections) | % { Remove-Connection $_.Id } I finally found the answer. I have to set the Get-Connections command in brackets: (Get-Connections) | % { Remove-Connection $_.Id }

如何确保资源显示在Chef服务器运行日志详细信息中(How to ensure resources show up in chef server run log details)

从报告数据中明确禁止嵌套资源: https : //github.com/chef/chef/blob/master/lib/chef/resource_reporter.rb#L312-L315 你必须为此建立自己的系统。 Nested resources are explicitly suppressed from the reporting data: https://github.com/chef/chef/blob/master/lib/chef/resource_reporter.r

在sqoop查询中连接两个表时的算术运算(Arithmetic operation while joining two tables in a sqoop query)

YEAR和MONTH无效Teradata SQL,都是ODBC语法,由ODBC驱动程序自动重写。 尝试EXTRACT(YEAR FROM A.dt) 。 YEAR and MONTH are not valid Teradata SQL, both are ODBC syntax, which is automatically rewritten by the ODBC driver. Try EXTRACT(YEAR FROM A.dt) instead.

相关文章

更多

最新问答

更多
  • 根据Woocommerce中的自定义字段计算自定义购物车商品价格(Custom cart item price calculation based on dimentions custom fields in Woocommerce)
  • 分开foreach项目并单独打印(Separate foreach items and print them individually)
  • 写模式管道是否同步?(Is write mode pipe synchronous?)
  • 发现可用的Windows Phone强调色和本地化名称(Discover available Windows Phone accent colors and localized names)
  • 使用多线程和WPF更新集合(Update Collection with multithreading and WPF)
  • 如何在字符串的情况下使用同步?(How should the synchronization be used in case of strings?)
  • 打印唯一的行,比较不超过N个字符(Print unique lines, compare no more than N characters)
  • Javascript / jQuery - 如何调用switch case从另一个函数执行(Javascript/jQuery - how to call a switch case to execute from another function)
  • Hbase超时错误不断发生(Hbase timeout errors keep occuring)
  • 如何在Delphi中更改TabControl中活动TAB的颜色(How to change the color of active TAB in a TabControl, in Delphi)
  • 正则表达式:在sublime文本中替换一些PHP代码(Regex: replace some pieces of php code in sublime text)
  • 在带有Scene2D的LibGDX中,如何在按下按钮时连续向右走?(In LibGDX with Scene2D, how can I continuously walk to the right when a button is pressed?)
  • 累加器如何在Haskell中工作?(How do accumulators work in Haskell?)
  • 使用开关检查市场和前缀与正确的货币符号(using switch to check market and prefix with correct currency symbol)
  • 在哪里分配一次使用类?(Where to allocate one time use class?)
  • 如何从两个DateTime / NaiveDateTime获取持续时间?(How do I get Duration from two DateTime / NaiveDateTime?)
  • 解析TimeSpan大于24小时?(Parse a TimeSpan greater than 24 hours? [duplicate])
  • 如何在球拍中本地更改阅读规则?(How to locally change reading rules in racket?)
  • 数据库应该由DI注入时的模拟存储(通过构造函数)(Mock storage when database should be injected by DI (through constructor))
  • 使用maven集成2个eclipse项目(Integrate 2 eclipse projects using maven)
  • 角度ng-repeat不检测变化(Angular ng-repeat not detecting changes)
  • Xaml组件在Silverlight + XNA应用程序的多个页面中可见(Xaml component visible in multiple pages in Silverlight+XNA applications)
  • 如何将`var`变量等同于另一个查询(How to equate `var` variable to another query)
  • 如何设计hyperledger链代码以适合您的业务?(how to design your chaincode of hyperledger to fit for your business?)
  • PHP readfile错误(PHP readfile error)
  • 在Date之后排序列表然后是时间(Sorting list after Date then time)
  • Android内部版本号(Android build number)
  • 在没有预设退出条件的情况下停止无限循环(stopping an infinite loop with no preset exit condition)
  • Phonegap应用程序全屏通过html页面中的按钮(Phonegap Application fullscreen through a button in html page)
  • PAA是否适合在门户网站中自动执行wcm库部署和设置?(Is PAA a good candidate for automating wcm library deployment and setup in portal?)