|
@@ -8,7 +8,9 @@ import def_pb2 as pb
|
|
|
from concurrent.futures import ThreadPoolExecutor, as_completed, wait
|
|
|
import GrpcClient as rpc
|
|
|
import vtk
|
|
|
-from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
|
|
|
+from vtkmodules.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
|
|
|
+#from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
|
|
|
+
|
|
|
import threading
|
|
|
class ControlFrame(QFrame):
|
|
|
def __init__(self):
|
|
@@ -131,17 +133,12 @@ class ImageViewer(QLabel):
|
|
|
self.image=None
|
|
|
self.show = False
|
|
|
self.setStyleSheet("border-width:1px;border-style:solid;border-color:rgb(150,150,150)")
|
|
|
- self.timer=QTimer()
|
|
|
- self.timer.timeout.connect(self.OnTimer)
|
|
|
- def FlashImg(self,pixmap):
|
|
|
- self.image=pixmap
|
|
|
- if self.timer.isActive()==False:
|
|
|
- self.timer.start(500)
|
|
|
+
|
|
|
def ShowImg(self,pixmap):
|
|
|
- self.timer.stop()
|
|
|
self.show=True
|
|
|
self.image=pixmap
|
|
|
- self.repaint()
|
|
|
+ self.update()
|
|
|
+
|
|
|
def updataData(self):
|
|
|
self.OnAction(self.dtype,self.id)
|
|
|
print("%d,%d"%(self.dtype,self.id))
|
|
@@ -153,17 +150,12 @@ class ImageViewer(QLabel):
|
|
|
menu.addAction(updata_act)
|
|
|
ret=menu.exec_(a0.globalPos())
|
|
|
|
|
|
- def OnTimer(self):
|
|
|
- self.show=not self.show
|
|
|
- self.repaint()
|
|
|
-
|
|
|
def paintEvent(self, a0: QPaintEvent) -> None:
|
|
|
- if self.show==True:
|
|
|
- if not self.image == None:
|
|
|
- w, h = self.size().width(),self.size().height()
|
|
|
- iw, ih = self.image.width(), self.image.height()
|
|
|
- painter=QPainter(self)
|
|
|
- painter.drawPixmap(QRect(0,0,w,h),self.image,QRect(0,0,iw,ih))
|
|
|
+ if not self.image == None:
|
|
|
+ w, h = self.size().width(),self.size().height()
|
|
|
+ iw, ih = self.image.width(), self.image.height()
|
|
|
+ painter=QPainter(self)
|
|
|
+ painter.drawPixmap(QRect(0,0,w,h),self.image,QRect(0,0,iw,ih))
|
|
|
|
|
|
|
|
|
class VtkPointCloud:
|
|
@@ -246,6 +238,10 @@ class VtkPointCloudCanvas(QWidget):
|
|
|
self.show()
|
|
|
self._iren.Initialize()
|
|
|
|
|
|
+ def close(self) -> bool:
|
|
|
+
|
|
|
+ print(" tk close")
|
|
|
+ self._point_cloud.clearPoints()
|
|
|
|
|
|
def displayPCL(self,cloud:np.array):
|
|
|
colors = vtk.vtkUnsignedCharArray()
|
|
@@ -255,15 +251,11 @@ class VtkPointCloudCanvas(QWidget):
|
|
|
self._point_cloud.clearPoints()
|
|
|
for point in cloud:
|
|
|
self._point_cloud.addPoint(point)
|
|
|
- if point[-1]>0.85:
|
|
|
- colors.InsertNextTypedTuple((0,255,0))
|
|
|
- else:
|
|
|
- colors.InsertNextTypedTuple((255,255,255))
|
|
|
+ prob=point[-1]
|
|
|
+ colors.InsertNextTypedTuple((int(255*prob),int(255-prob*255),255-int(prob*255)))
|
|
|
self._point_cloud.vtkPolyData.GetPointData().SetScalars(colors)
|
|
|
self._vtk_widget.update()
|
|
|
- #self._vtk_widget.GetRenderWindow().Render()
|
|
|
def resetViewer(self):
|
|
|
-
|
|
|
self.update()
|
|
|
|
|
|
|
|
@@ -284,10 +276,9 @@ class PointCLViwer(QSplitter):
|
|
|
print(fileName2 ,ok2)
|
|
|
with open(fileName2,"w+") as f:
|
|
|
for point in self.pointCloud:
|
|
|
- if point[3]>0.85:
|
|
|
- f.write("%f %f %f 0 255 0\n"%(point[0],point[1],point[2]))
|
|
|
- else:
|
|
|
- f.write("%f %f %f 255 255 255\n"%(point[0],point[1],point[2]))
|
|
|
+ prob=point[3]
|
|
|
+ f.write("%f %f %f %d %d %d\n"%(point[0],point[1],point[2],int(255*prob),int(255-prob*255),255-int(prob*255)))
|
|
|
+
|
|
|
print("Save Cloud to %s"%(fileName2))
|
|
|
|
|
|
def displayCloud(self,points:np.array):
|
|
@@ -312,6 +303,7 @@ class PointCLViwer(QSplitter):
|
|
|
menu.addAction(actSave)
|
|
|
ret=menu.exec_(a0.globalPos())
|
|
|
|
|
|
+
|
|
|
class ViewerFrame(QFrame):
|
|
|
def __init__(self,OnAction):
|
|
|
super(ViewerFrame, self).__init__()
|