我正在尝试将坐标从颜色空间映射到相机空间。 我使用的代码如下:
HRESULT ModelRecognizer::MapColorToCameraCoordinates(const std::vector<ColorSpacePoint>& colorsps, std::vector<CameraSpacePoint>& camerasps)
{
//Access frame
HRESULT hr = GetDepthFrame();
if (SUCCEEDED(hr))
{
ICoordinateMapper* pMapper;
hr = m_pKinectSensor->get_CoordinateMapper(&pMapper);
if (SUCCEEDED(hr))
{
CameraSpacePoint* cameraSpacePoints = new CameraSpacePoint[cColorWidth * cColorHeight];
hr = pMapper->MapColorFrameToCameraSpace(nDepthWidth * nDepthHeight, depthImageBuffer, cColorWidth * cColorHeight, cameraSpacePoints);
if (SUCCEEDED(hr))
{
for (ColorSpacePoint colorsp : colorsps)
{
long colorIndex = (long)(colorsp.Y * cColorWidth + colorsp.X);
CameraSpacePoint csp = cameraSpacePoints[colorIndex];
camerasps.push_back(csp);
}
}
delete[] cameraSpacePoints;
}
}
ReleaseDepthFrame();
return hr;
}
我没有收到任何错误,但是,结果似乎旋转了 180 度并且有一个偏移量。有没有人建议我做错了什么?感谢您的帮助。
只是为了更全面地说明为什么我需要这个:
我正在使用开放式简历从彩色图像中跟踪粘贴在 table 上的彩色胶带。然后我在 3D 网格中的胶带位置创建墙。此外,我正在使用 KinectFusion 生成 table 上其他对象的网格。但是,当我在 Meshlab 中打开两个网格时,可以清楚地看到错位。由于我假设 KinectFusion 的网格是在 CameraSpace 中正确创建的,并且我在上述函数返回的 CameraSpacePoints 处准确创建了墙壁的网格,所以我很确定错误出在 CoordinateMapping 过程中。
可以在 http://imgur.com/UsrEdZb,ZseN2br#0 找到显示错位的图像, http://imgur.com/UsrEdZb,ZseN2br#1
最佳答案
我终于弄明白了:无论出于何种原因,返回的 CameraSpacePoints 在 X 和 Y 的原点处进行了镜像,而不是在 Z 中。如果有人对此有解释,我仍然很感兴趣。
现在可以使用以下代码:
/// <summary>
/// Maps coordinates from ColorSpace to CameraSpace
/// Expects that the Points in ColorSpace are mirrored at x (as Kinects returns it by default).
/// </summary>
HRESULT ModelRecognizer::MapColorToCameraCoordinates(const std::vector<ColorSpacePoint>& colorsps, std::vector<CameraSpacePoint>& camerasps)
{
//Access frame
HRESULT hr = GetDepthFrame();
if (SUCCEEDED(hr))
{
ICoordinateMapper* pMapper;
hr = m_pKinectSensor->get_CoordinateMapper(&pMapper);
if (SUCCEEDED(hr))
{
CameraSpacePoint* cameraSpacePoints = new CameraSpacePoint[cColorWidth * cColorHeight];
hr = pMapper->MapColorFrameToCameraSpace(nDepthWidth * nDepthHeight, depthImageBuffer, cColorWidth * cColorHeight, cameraSpacePoints);
if (SUCCEEDED(hr))
{
for (ColorSpacePoint colorsp : colorsps)
{
int colorX = static_cast<int>(colorsp.X + 0.5f);
int colorY = static_cast<int>(colorsp.Y + 0.5f);
long colorIndex = (long)(colorY * cColorWidth + colorX);
CameraSpacePoint csp = cameraSpacePoints[colorIndex];
camerasps.push_back(CameraSpacePoint{ -csp.X, -csp.Y, csp.Z });
}
}
delete[] cameraSpacePoints;
}
}
ReleaseDepthFrame();
return hr;
}
关于c++ - Kinect v2 将颜色坐标映射到相机空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27889646/
我的瘦服务器配置了nginx,我的ROR应用程序正在它们上运行。在我发布代码更新时运行thinrestart会给我的应用程序带来一些停机时间。我试图弄清楚如何优雅地重启正在运行的Thin实例,但找不到好的解决方案。有没有人能做到这一点? 最佳答案 #Restartjustthethinserverdescribedbythatconfigsudothin-C/etc/thin/mysite.ymlrestartNginx将继续运行并代理请求。如果您将Nginx设置为使用多个上游服务器,例如server{listen80;server
我想在一个没有Sass引擎的类中使用Sass颜色函数。我已经在项目中使用了sassgem,所以我认为搭载会像以下一样简单:classRectangleincludeSass::Script::FunctionsdefcolorSass::Script::Color.new([0x82,0x39,0x06])enddefrender#hamlengineexecutedwithcontextofself#sothatwithintemlateicouldcall#%stop{offset:'0%',stop:{color:lighten(color)}}endend更新:参见上面的#re
如何使用Ruby的默认Curses库获取颜色?所以像这样:puts"\e[0m\e[30;47mtest\e[0m"效果很好。在浅灰色背景上呈现漂亮的黑色。但是这个:#!/usr/bin/envrubyrequire'curses'Curses.noecho#donotshowtypedkeysCurses.init_screenCurses.stdscr.keypad(true)#enablearrowkeys(forpageup/down)Curses.stdscr.nodelay=1Curses.clearCurses.setpos(0,0)Curses.addstr"Hello
状态:我正在构建一个应用程序,其中需要一个可供用户选择颜色的字段,该字段将包含RGB颜色代码字符串。我已经测试了一个看起来很漂亮但效果不佳的。它是“挑剔的颜色”,并托管在此存储库中:https://github.com/Astorsoft/picky-color.在这里我打开一个关于它的一些问题的问题。问题:请建议我在Rails3应用程序中使用一些颜色选择器。 最佳答案 也许页面上的列表jQueryUIDevelopment:ColorPicker为您提供开箱即用的产品。原因是jQuery现在包含在Rails3应用程序中,因此使用基
如何将send与+=一起使用?a=20;a.send"+=",10undefinedmethod`+='for20:Fixnuma=20;a+=10=>30 最佳答案 恐怕你不能。+=不是方法,而是语法糖。参见http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_expressions.html它说Incommonwithmanyotherlanguages,Rubyhasasyntacticshortcut:a=a+2maybewrittenasa+=2.你能做的最好的事情是:
我们目前正在为ROR3.2开发自定义cms引擎。在这个过程中,我们希望成为我们的rails应用程序中的一等公民的几个类类型起源,这意味着它们应该驻留在应用程序的app文件夹下,它是插件。目前我们有以下类型:数据源数据类型查看我在app文件夹下创建了多个目录来保存这些:应用/数据源应用/数据类型应用/View更多类型将随之而来,我有点担心应用程序文件夹被这么多目录污染。因此,我想将它们移动到一个子目录/模块中,该子目录/模块包含cms定义的所有类型。所有类都应位于MyCms命名空间内,目录布局应如下所示:应用程序/my_cms/data_source应用程序/my_cms/data_ty
📢博客主页:https://blog.csdn.net/weixin_43197380📢欢迎点赞👍收藏⭐留言📝如有错误敬请指正!📢本文由Loewen丶原创,首发于CSDN,转载注明出处🙉📢现在的付出,都会是一种沉淀,只为让你成为更好的人✨文章预览:一.分辨率(Resolution)1、工业相机的分辨率是如何定义的?2、工业相机的分辨率是如何选择的?二.精度(Accuracy)1、像素精度(PixelAccuracy)2、定位精度和重复定位精度(RepeatPrecision)三.公差(Tolerance)四.课后作业(Post-ClassExercises)视觉行业的初学者,甚至是做了1~2年
我对如何计算通过{%assignvar=0%}赋值的变量加一完全感到困惑。这应该是最简单的任务。到目前为止,这是我尝试过的:{%assignamount=0%}{%forvariantinproduct.variants%}{%assignamount=amount+1%}{%endfor%}Amount:{{amount}}结果总是0。也许我忽略了一些明显的东西。也许有更好的方法。我想要存档的只是获取运行的迭代次数。 最佳答案 因为{{incrementamount}}将输出您的变量值并且不会影响{%assign%}定义的变量,我
如果names为nil,则以下中断。我怎样才能让这个map只有在它不是nil时才执行?self.topics=names.split(",").mapdo|n|Topic.where(name:n.strip).first_or_create!end 最佳答案 其他几个选项:选项1(在其上执行map时检查split的结果):names_list=names.try(:split,",")self.topics=names_list.mapdo|n|Topic.where(name:n.strip).first_or_create!e
我有一个数组数组,想将元素附加到子数组。+=做我想做的,但我想了解为什么push不做。我期望的行为(并与+=一起工作):b=Array.new(3,[])b[0]+=["apple"]b[1]+=["orange"]b[2]+=["frog"]b=>[["苹果"],["橙子"],["Frog"]]通过推送,我将推送的元素附加到每个子数组(为什么?):a=Array.new(3,[])a[0].push("apple")a[1].push("orange")a[2].push("frog")a=>[[“苹果”、“橙子”、“Frog”]、[“苹果”、“橙子”、“Frog”]、[“苹果”、“