在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();
但是,当我重叠两者时,生成的图像如下:
红色和蓝色云应该完美匹配。 有没有办法“合并”积分? 也就是说,考虑到点位置匹配,我可以改变匹配位置的颜色吗? 仅使用点进行渲染而不进行网格划分。
我尝试在渲染之前比较两个向量,但算法最终太慢了,因为点云太大了。
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:
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
最满意答案
问题在于这一行:
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 ...
-
线程不会同时运行(Threads don't run simultaneously)[2022-10-10]
问题在于这一行: t = threading.Thread(target=PutWorker(numValue),daemon = True) 实际上,您正在调用 PutWorker将目标指向线程。 所有这些都是在线程实际创建之前发生的。 你应该传递函数本身。 所以像这样: t = threading.Thread(target=PutWorker, ... 没有参数,没有调用,它只是一个函数(Thread将调用来启动线程) 因为它有一个参数,所以你需要“咖哩”,我会这样做: from functool ... -
为什么这些线程化的ActiveRecord查询不会同时运行?(Why won't these threaded ActiveRecord queries run concurrently?)[2023-08-11]
一些评论: 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 ...