首页 \ 问答 \ 在OpenGL中绘制两个点云之间的交点(Draw Intersection between two point clouds in OpenGL)

在OpenGL中绘制两个点云之间的交点(Draw Intersection between two point clouds in OpenGL)

我有两个相似的点云,由一个在空间中给定位置(x,y,z)的矢量定义,我想同时渲染两个云并评估它们之间的差异。 这是我第一次使用OpenGL的应用程序,所以我仍然没有太多掌握使用它。

我已经设法通过分别处理每个向量来渲染它们,例如:

    glBegin(GL_POINTS);GLfloat green[] = { 0.f, 1.0f, .0f, alpha[1]/10 };
    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, green);
    glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, low_shininess);
    //glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
    for (std::vector<Point3D>::iterator moit = morig_cloud.begin(); moit != morig_cloud.end(); ++moit){
        if ((moit - f_cloud.begin()) % (ptd[1]) == 0){
            glVertex3f(moit->x, moit->y, moit->z);
        }
    }
    glEnd();

但是,当我重叠两者时,生成的图像如下: 1

红色和蓝色云应该完美匹配。 有没有办法“合并”积分? 也就是说,考虑到点位置匹配,我可以改变匹配位置的颜色吗? 仅使用点进行渲染而不进行网格划分。

我尝试在渲染之前比较两个向量,但算法最终太慢了,因为点云太大了。


I have two similar point clouds, defined by a vector with their given positions (x,y,z) in space, and I want to render both clouds simultaneously and evaluate the differences between them. This is my first application using OpenGL so I still have not much grasp using it.

I've managed to render both of them by processing each vector separately, such as:

    glBegin(GL_POINTS);GLfloat green[] = { 0.f, 1.0f, .0f, alpha[1]/10 };
    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, green);
    glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, low_shininess);
    //glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
    for (std::vector<Point3D>::iterator moit = morig_cloud.begin(); moit != morig_cloud.end(); ++moit){
        if ((moit - f_cloud.begin()) % (ptd[1]) == 0){
            glVertex3f(moit->x, moit->y, moit->z);
        }
    }
    glEnd();

However, when I overlap both, the resulting image is as follows: 1

Where both the red and the blue clouds are supposed to match perfectly. Is there any way to "merge" the points? That is, considering that the points position match, I can change the color for the matching locations? The rendering is done with points only without meshing.

I tried comparing both vectors before rendering but the algorithm ended up being too slow, as the point clouds are too big.


原文:https://stackoverflow.com/questions/23007263
更新时间:2023-03-04 19:03

最满意答案

问题在于这一行:

t = threading.Thread(target=PutWorker(numValue),daemon = True)

实际上,您正在调用 PutWorker将目标指向线程。 所有这些都是在线程实际创建之前发生的。 你应该传递函数本身。

所以像这样:

t = threading.Thread(target=PutWorker, ...

没有参数,没有调用,它只是一个函数(Thread将调用来启动线程)

因为它有一个参数,所以你需要“咖哩”,我会这样做:

from functools import partial

...

t = threading.Thread(target=partial(PutWorker, numValue), ...

The problem is with this line:

t = threading.Thread(target=PutWorker(numValue),daemon = True)

You're actually calling PutWorker to get the target to Thread. So it's all happening before the thread is actually created. You should be passing in the function itself.

So something like:

t = threading.Thread(target=PutWorker, ...

No arguments, no call, it's just a function (which Thread will call to start the thread)

Since it has a parameter, you need to "Curry" that in. I'd do it like this:

from functools import partial

...

t = threading.Thread(target=partial(PutWorker, numValue), ...

相关问答

更多
  • 就在这里! $(function () { $("#first").animate({ width: '200px' }, { duration: 200, queue: false }); $("#second").animate({ width: '600px' }, { duration: 200, queue: false }); }); yes there is! $(function () { $("#first").ani ...
  • 我们假设您的机器有一个处理器。 任何时候只能运行一个线程。 如果多个进程正在运行,它们每个都会在处理器上接收一段时间,然后通过某种调度算法进行交换。 在您的情况下,当数字为4时,线程可以在换出之前完成其工作。 完成后,处于等待状态的任何其他线程都可以运行。 T1>开始>执行>终止 T2>开始>执行>终止 当您将数量增加到一百万时,线程只能在调度程序分配的时间内执行其部分工作。 一旦这个时间结束,它将由调度程序换出,并且处于等待状态的另一个线程将运行。 T1>启动>执行时间x>移动到等待状态 T2>开始>执行 ...
  • 您的问题是target=关键字现在设置为函数的返回值 。 你想拥有这个功能 。 那么,现在实际发生的是: 调用Function1() t1的目标设置为None ( Function1()返回值 对于Function2()和t2重复1-2次。 启动t1和t2线程,两者都具有None作为目标。 这没有效果。 更换 t1= Thread(target=Function1()) t2= Thread(target=Function2()) 同 t1= Thread(target=Function1) t2= Th ...
  • 我会建议反对重新修补的线程,这是一个相当严重的开销。 相反,创建一个由N个线程组成的池,并通过工作队列(一种相当标准的方法)向他们提交工作。 即使你的剩余工作少于N,额外的线程也不会造成任何伤害,他们只会呆在工作队列中。 如果你坚持你目前的做法,你可以这样做: 不要等待带有pthread_join线程,你不需要它,因为你没有把任何东西传回主线程。 创建具有属性PTHREAD_CREATE_DETACHED的线程并让它们退出。 在主线程中,等待一个信号量,它由每个退出的线程发出信号 - 实际上,您将等待任何线 ...
  • 它与你的tinder-ping元素的初始位置有关。 它们都是全尺寸的,因此有效的动画似乎没有工作,直到第三个动画最终调整为小。 您必须使用实际设置,但设置ping 1,2和3 -webkit-transform: scale(0, 0); transform: scale(0, 0); opacity: 0; 初始值使其更好。 您可能还需要测试z索引,但这是一个可以开始的地方。 本质上,你的第三个ping是隐藏其他两个,因为它是动画延迟后的520x520像素。 It has to do ...
  • 问题在于这一行: t = threading.Thread(target=PutWorker(numValue),daemon = True) 实际上,您正在调用 PutWorker将目标指向线程。 所有这些都是在线程实际创建之前发生的。 你应该传递函数本身。 所以像这样: t = threading.Thread(target=PutWorker, ... 没有参数,没有调用,它只是一个函数(Thread将调用来启动线程) 因为它有一个参数,所以你需要“咖哩”,我会这样做: from functool ...
  • 一些评论: rails 2.3本身并不是真正的线程安全,因为rails 3.x就是这样。 但对于这种情况,我认为并不重要。 你应该至少使用ruby 1.9。 1.8中的“绿色线程”不是最佳的。 虽然在红宝石1.9中踩踏仍然不是最佳的,但它更好。 对于真正的线程,你应该检查jruby或rubinius(没有GIL)。 你应该使用mysql2 gem。 mysql gem在等待数据库响应时保留GIL。 Some remarks: rails 2.3 itself is afaik itself not real ...
  • 我们可以在不同的操作系统中使用--xmlrpc-port = port_number运行两个OpenERP / Odoo版本 Where port_number will indicate number. 我们也可以这样做,创建两个postgres用户。 OpenERP的 odoo 现在创建两个系统用户: OpenERP的 odoo 使用适当的用户配置OpenERP / Odoo的核心模块。 使用--xmlrpc-port = 9999启动服务器 你可以给他们任意号码。 我给了9999,所以我将在浏览器 ...
  • 所以你的想法会奏效。 如果您在下面尝试此代码。 System.out.println(System.currentTimeMillis()); System.out.println(System.currentTimeMillis()); 您会发现时间实际上是相同的,这意味着这两行几乎同时执行。 就你的代码而言: Thread runner1 = new Thread(new Runner(), "Runner 1"); runner1.start(); Thread runner2 = new Thr ...
  • 我认为你需要的是信号量 。 检查文档。 简而言之,信号量是一种锁定方法。 你从信号量单例类中询问资源,这是进程范围唯一,控制函数进程的运行数。 I think what you need is semaphore. Check the doc. Briefly speaking, semaphore is a locking method. You ask the resource from the semaphore singleton class, which is process scope uniq ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。