Skip to content

Commit

Permalink
Merge pull request #63 from zivid/2023-09-12-update-halcon-samples
Browse files Browse the repository at this point in the history
Samples: Fix PLY loading and using M60 and L110
  • Loading branch information
SatjaSivcev authored Oct 21, 2023
2 parents 0e74dfe + 67e150e commit a67b479
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@
<l>import './../../../Procedures'</l>
<l>get_zivid_sample_data_dir(ZividDataDir)</l>
<l>ScenePath := ZividDataDir + '/ObjectMatching/' + SurfaceModelFile + '/Im1.ply'</l>
<l>read_object_model_3d (ScenePath, 'm', ['xyz_map_width'], [1920], ObjectModel3D_Scene, Status)</l>
<c>* Specify the camera that point cloud was taken with; options are: 'Zivid One+', 'Zivid 2', and 'Zivid 2+'.</c>
<l>Camera := 'Zivid One+'</l>
<c>* Specify SamplingPixel that point cloud was taken with; options are: 'all', 'blueSubsample2x2', and 'redSubsample2x2'</c>
<l>SamplingPixel := 'all'</l>
<l>get_zivid_camera_width (Camera, SamplingPixel, MapWidth)</l>
<l>read_object_model_3d (ScenePath, 'm', ['xyz_map_width'], MapWidth, ObjectModel3D_Scene, Status)</l>
<c/>
<c>* Fixing to make the point cloud appear with colors</c>
<l>get_object_model_3d_params (ObjectModel3D_Scene, 'red', red)</l>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<l> set_framegrabber_param (AcqHandle, 'ExposureTime', 10000)</l>
<l> set_framegrabber_param (AcqHandle, 'Aperture', 4.36)</l>
<l> set_framegrabber_param (AcqHandle, 'AddAcquisition', 1)</l>
<l> set_framegrabber_param (AcqHandle, 'Aperture', 2.10)</l>
<l> set_framegrabber_param (AcqHandle, 'Aperture', 2.37)</l>
<l> set_framegrabber_param (AcqHandle, 'AddAcquisition', 1)</l>
<l>endif</l>
<c>* Coca-Cola bottle</c>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
<l>import './../../../Procedures'</l>
<l>get_zivid_sample_data_dir(ZividDataDir)</l>
<l>ScenePath := ZividDataDir + '/ObjectMatching/' + SurfaceModelFile</l>
<c>* Specify the camera that point cloud was taken with; options are: 'Zivid One+', 'Zivid 2', and 'Zivid 2+'.</c>
<l>Camera := 'Zivid One+'</l>
<c>* Specify SamplingPixel that point cloud was taken with; options are: 'all', 'blueSubsample2x2', and 'redSubsample2x2'</c>
<l>SamplingPixel := 'all'</l>
<l>get_zivid_camera_width (Camera, SamplingPixel, MapWidth)</l>
<c/>
<c>* Specify whether you want to use your own model created with the SurfaceMatchingCreateModelFromFile.hdev</c>
<l>MySurfaceModelFile := false</l>
Expand All @@ -59,7 +64,7 @@
<l> tuple_add (ScenePath, '/Im', SceneFilename)</l>
<l> tuple_add (SceneFilename, Index, SceneFilename)</l>
<l> tuple_add (SceneFilename, '.ply', SceneFilename) </l>
<l> read_object_model_3d (SceneFilename, 'm', ['xyz_map_width'], [1920], ObjectModel3DScene, Status)</l>
<l> read_object_model_3d (SceneFilename, 'm', ['xyz_map_width'], MapWidth, ObjectModel3DScene, Status)</l>
<c/>
<c> * Fixing to make the point cloud appear with colors</c>
<l> get_object_model_3d_params (ObjectModel3DScene, 'red', red)</l>
Expand Down
9 changes: 7 additions & 2 deletions source/Applications/Basic/FileFormats/ReadPLY.hdev
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@
<l>dev_open_window (0, 0, WinWidth, WinHeight, 'black', Window2D)</l>
<l>dev_open_window (0, WinWidth, WinWidth, WinHeight, 'blue', Window3D)</l>
<c/>
<c>* Reading PCD point cloud from file</c>
<c>* Reading PLY point cloud from file</c>
<l>import './../../../Procedures'</l>
<l>get_zivid_sample_data_dir(ZividDataDir)</l>
<l>PointCloudFile := ZividDataDir + '/Zivid3D.ply'</l>
<l>read_object_model_3d (PointCloudFile, 'mm', ['xyz_map_width'], [1920], ObjectModel3D, Status)</l>
<c>* Specify the camera that point cloud was taken with; options are: 'Zivid One+', 'Zivid 2', and 'Zivid 2+'.</c>
<l>Camera := 'Zivid One+'</l>
<c>* Specify SamplingPixel that point cloud was taken with; options are: 'all', 'blueSubsample2x2', and 'redSubsample2x2'</c>
<l>SamplingPixel := 'all'</l>
<l>get_zivid_camera_width (Camera, SamplingPixel, MapWidth)</l>
<l>read_object_model_3d (PointCloudFile, 'mm', ['xyz_map_width'], MapWidth, ObjectModel3D, Status)</l>
<c/>
<c>* Fixing to make the point cloud appear with colors</c>
<l>get_object_model_3d_params (ObjectModel3D, 'red', red)</l>
Expand Down
42 changes: 42 additions & 0 deletions source/Procedures/get_zivid_camera_width.hdvp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<hdevelop file_version="1.2" halcon_version="21.11.0.0">
<procedure name="get_zivid_camera_width">
<interface>
<ic>
<par name="Camera" base_type="ctrl" dimension="0"/>
<par name="SamplingPixel" base_type="ctrl" dimension="0"/>
</ic>
<oc>
<par name="Width" base_type="ctrl" dimension="0"/>
</oc>
</interface>
<body>
<l>if (Camera == 'Zivid One+')</l>
<l> Width := 1920</l>
<l>elseif (Camera == 'Zivid 2')</l>
<l> Width := 1944</l>
<l>elseif (Camera == 'Zivid 2+')</l>
<l> Width := 2448</l>
<l>else</l>
<l> throw('Unsupported camera: ' + Camera)</l>
<l>endif</l>
<c/>
<l>if (SamplingPixel == 'blueSubsample2x2')</l>
<l> Width := Width/2</l>
<l>elseif (SamplingPixel == 'redSubsample2x2')</l>
<l> Width := Width/2</l>
<l>elseif (SamplingPixel != 'all')</l>
<l> throw('Unsupported SamplingPixel: ' + SamplingPixel) </l>
<l>endif</l>
<c/>
<l>return ()</l>
</body>
<docu id="get_zivid_camera_width">
<parameters>
<parameter id="Camera"/>
<parameter id="SamplingPixel"/>
<parameter id="Width"/>
</parameters>
</docu>
</procedure>
</hdevelop>

0 comments on commit a67b479

Please sign in to comment.