@@ -177,14 +177,10 @@ def __init__(self):
177177 self .timer_thread .start ()
178178 self .image_timer_thread .start ()
179179
180- path = "/media/nu94waro/Windows_C/save/datasets/HLEDataset/dataset"
181180
181+ # (UN)COMMENT THIS TO LOAD HLE DATA AFTER STARTING
182182 '''
183- self.loadData(
184- "assets/camera_calibration.json",
185- "assets/laser_calibration.json",
186- "assets/example_vid.avi",
187- )'''
183+ path = "/media/nu94waro/Windows_C/save/datasets/HLEDataset/dataset"
188184
189185 self.menu_widget.widget().ocs_widget.camera_calib_path = os.path.join(path, "camera_calibration.json")
190186 self.menu_widget.widget().ocs_widget.laser_calib_path = os.path.join(path, "laser_calibration.json")
@@ -201,7 +197,30 @@ def __init__(self):
201197 point_tracking.PointTracker(),
202198 correspondence_estimation.BruteForceEstimator(10, 30, 40, 100),
203199 surface_reconstruction.SurfaceReconstructor())
200+ '''
201+
202+ # (UN)COMMENT THIS TO LOAD SILICONE DATA AFTER STARTING
203+
204+ path = "assets"
204205
206+ self .menu_widget .widget ().ocs_widget .camera_calib_path = os .path .join (path , "camera_calibration.json" )
207+ self .menu_widget .widget ().ocs_widget .laser_calib_path = os .path .join (path , "laser_calibration.json" )
208+ self .loadData (
209+ "assets/camera_calibration.json" ,
210+ "assets/laser_calibration.json" ,
211+ "assets/example_vid.avi" ,
212+ )
213+
214+ self ._reconstruction_pipeline = reconstruction_pipeline .ReconstructionPipeline (
215+ self .camera ,
216+ self .laser ,
217+ feature_estimation .SiliconeFeatureEstimator (),
218+ point_tracking .SiliconePointTracker (),
219+ correspondence_estimation .BruteForceEstimator (10 , 30 , 40 , 100 ),
220+ surface_reconstruction .SurfaceReconstructor ())
221+
222+
223+
205224 '''
206225 glottal_outline_images = torch.from_numpy(np.load("load/glottal_outline_images.npy")).cuda()
207226 glottis_segmentations = torch.from_numpy(np.load("load/glottis_segmentations.npy",)).cuda()
@@ -634,8 +653,10 @@ def computeFeatures(self):
634653 else :
635654 print ("Please choose a Segmentation Algorithm" )
636655
656+ use_cuda = self .menu_widget .widget ().getSubmenuValue ("CUDA" , "Use" )
657+
637658 self ._reconstruction_pipeline .set_feature_estimator (feature_estimator )
638- self ._reconstruction_pipeline .estimate_features (self .video )
659+ self ._reconstruction_pipeline .estimate_features (self .video if use_cuda else self . video . cpu () )
639660
640661 self .graph_widget .updateGraph (
641662 feature_estimator .glottalAreaWaveform ().tolist (), self .graph_widget .glottal_seg_graph
@@ -650,12 +671,27 @@ def computeFeatures(self):
650671 self .image_widget .point_viewer .add_glottal_midlines (feature_estimator .glottalMidlines ())
651672 self .image_widget .point_viewer .add_glottal_outlines (feature_estimator .glottalOutlines ())
652673
674+
675+ self .update_images_func ()
653676 #self.segmentations = segmentations
654677 #self.laserdots = segmentations
655678
656679 def trackPoints (self ):
657- point_positions = self ._reconstruction_pipeline .track_points (self .video )
680+ use_cuda = self .menu_widget .widget ().getSubmenuValue ("CUDA" , "Use" )
681+
682+ point_tracker : point_tracking .PointTrackerBase = None
683+ if self .menu_widget .widget ().getSubmenuValue ("Point Tracking" , "Invivo" ):
684+ point_tracker = point_tracking .InvivoPointTracker ()
685+ elif self .menu_widget .widget ().getSubmenuValue ("Point Tracking" , "Silicone" ):
686+ point_tracker = point_tracking .SiliconePointTracker ()
687+ else :
688+ print ("Please choose a Segmentation Algorithm" )
689+
690+ self ._reconstruction_pipeline .set_point_tracker (point_tracker )
691+ point_positions = self ._reconstruction_pipeline .track_points (self .video if use_cuda else self .video .cpu ())
658692 self .image_widget .point_viewer .add_optimized_points (point_positions .detach ().cpu ().numpy ())
693+
694+ self .update_images_func ()
659695
660696 def buildCorrespondences (self ):
661697 min_search_space = float (
@@ -738,6 +774,7 @@ def denseShapeEstimation(self):
738774 psi = psi ,
739775 ARAP_iterations = ARAP_iterations ,
740776 ARAP_weight = ARAP_weight ,
777+ flip_y = False if self .menu_widget .widget ().getSubmenuValue ("Point Tracking" , "Silicone" ) else True
741778 )
742779
743780 self .point_cloud_offsets = [0 ]
@@ -809,10 +846,6 @@ def denseShapeEstimation(self):
809846 self .pointcloud_go_mesh_core = self .viewer_widget .get_mesh (self .pointcloud_go_instance_id ).mesh_core
810847
811848
812-
813-
814-
815-
816849 self .controlpoints_offsets = [0 ]
817850 self .controlpoints_elements = [len (self .leftDeformed [0 ]) + len (self .rightDeformed [0 ])]
818851
@@ -823,17 +856,13 @@ def denseShapeEstimation(self):
823856
824857 super_pc_controlpoints = np .concatenate ([np .array (self .leftDeformed ), np .array (self .rightDeformed )], axis = 1 )
825858 super_pc_controlpoints = np .concatenate (super_pc_controlpoints )
826-
827- vertex_attributes = {}
828- if not "vertexColor" in vertex_attributes :
829- vertex_attributes ["vertexColor" ] = np .tile (
830- np .array ([0.0 , 1.0 , 1.0 ], dtype = np .float32 ), (super_pc_controlpoints .shape [0 ], 1 )
831- )
832-
859+
833860 # I'm so sorry for this.
834861 faces = []
835862 res_u = zSubdivisions
836863 res_v = len (self .leftDeformed [0 ]) // res_u
864+ half_verts = len (self .leftDeformed [0 ])
865+ num_verts = 2 * half_verts
837866 for b in range (len (self .leftDeformed )):
838867 a = b * num_verts
839868 for i in range (res_u - 1 ):
@@ -843,15 +872,15 @@ def denseShapeEstimation(self):
843872 p2 = p0 + res_v + 1
844873 p3 = p0 + res_v
845874 faces .append ([p0 , p1 , p2 , p3 ]) # a quad face
846- faces .append ([len ( self . leftDeformed [ 0 ]) + p0 , len ( self . leftDeformed [ 0 ]) + p1 , len ( self . leftDeformed [ 0 ]) + p2 , len ( self . leftDeformed [ 0 ]) + p3 ])
875+ faces .append ([half_verts + p0 , half_verts + p1 , half_verts + p2 , half_verts + p3 ])
847876
848877 core_id = GlMeshCoreId ()
849878 self .viewer_widget .add_mesh_ (core_id , super_pc_controlpoints , np .array (faces ))
850879 prefab_id = GlMeshPrefabId (core_id )
851880 self .viewer_widget .add_mesh_prefab_ (
852881 prefab_id ,
853882 shader = "wireframe" ,
854- vertex_attributes = vertex_attributes ,
883+ vertex_attributes = {} ,
855884 face_attributes = {},
856885 uniforms = {"lineColor" : np .array ([0.0 , 1.0 , 1.0 ])},
857886 )
0 commit comments