-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit: - Adds warmup sample - fixes a bug when reading camera model
- Loading branch information
Showing
5 changed files
with
209 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<hdevelop file_version="1.2" halcon_version="21.11.0.0"> | ||
<procedure name="main"> | ||
<interface/> | ||
<body> | ||
<c>*</c> | ||
<c>* A basic warm-up method for a Zivid camera with specified time and capture cycle.</c> | ||
<c>*</c> | ||
<c/> | ||
<c>* Preparing the graphics window</c> | ||
<l>dev_close_window ()</l> | ||
<l>WinWidth := 480</l> | ||
<l>WinHeight := 400</l> | ||
<l>dev_open_window (0, 0, WinWidth, WinHeight, 'black', Window3D)</l> | ||
<c/> | ||
<c>* Getting first available Zivid device</c> | ||
<l>info_framegrabber ('GenICamTL','device', Information, Devices)</l> | ||
<l>import './../../Procedures'</l> | ||
<l>get_first_available_zivid_device (Devices, Device)</l> | ||
<l>get_zivid_sample_data_dir(ZividDataDir)</l> | ||
<c/> | ||
<c>* Connecting to Zivid camera</c> | ||
<l>open_framegrabber ('GenICamTL',1, 1, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', Device, 0, 0, AcqHandle)</l> | ||
<c/> | ||
<l>WarmupTimeMinutes := 10</l> | ||
<l>CaptureCycle := 5</l> | ||
<c/> | ||
<c>* Reading JSON settings path</c> | ||
<l>get_framegrabber_param (AcqHandle, 'DeviceModelName', DeviceModelName)</l> | ||
<l>get_zivid_model_folder_name (DeviceModelName, DeviceModelFolder)</l> | ||
<l>read_dict (ZividDataDir + '/SettingsJson/' + DeviceModelFolder + '/Settings01.json', [], [], JsonSettings)</l> | ||
<l>read_zivid_json_params (AcqHandle, JsonSettings)</l> | ||
<c/> | ||
<l>dev_disp_text ('Starting warm up for: ' + WarmupTimeMinutes + ' minutes' , 'window', 60, 12, 'black', [], [])</l> | ||
<c/> | ||
<l>TimePast := 0</l> | ||
<l>WarmupTime := WarmupTimeMinutes * 60</l> | ||
<l>while(TimePast < WarmupTime) </l> | ||
<l> count_seconds(BeforeGrabData)</l> | ||
<l> grab_data (Image, Region, Contours, AcqHandle, Data)</l> | ||
<l> count_seconds(AfterGrabData)</l> | ||
<c> </c> | ||
<l> CaptureTime := AfterGrabData - BeforeGrabData</l> | ||
<c> </c> | ||
<l> if (CaptureTime < CaptureCycle)</l> | ||
<l> wait_seconds (CaptureCycle - CaptureTime) </l> | ||
<l> else</l> | ||
<l> dev_disp_text('Your capture time is longer than your desired capture cycle. Please increase the desired capture cycle.','window', 84, 12, 'black', [], [])</l> | ||
<l> endif</l> | ||
<c> </c> | ||
<l> TimePast := TimePast + max([CaptureTime, CaptureCycle])</l> | ||
<l> RemainingTime := WarmupTime - TimePast</l> | ||
<l> RemainingTimeSeconds := max2 (0, int(RemainingTime) % 60)</l> | ||
<l> RemainingTimeMinutes := int (RemainingTime - RemainingTimeSeconds) / 60</l> | ||
<l> dev_disp_text('Remaining time: ' + RemainingTimeMinutes + ' minutes, ' + RemainingTimeSeconds + ' seconds' , 'window', 106, 12, 'black', [], [])</l> | ||
<l>endwhile</l> | ||
<c/> | ||
<l>dev_disp_text('Warm up completed', 'window', 120, 12, 'black', [], [])</l> | ||
<c/> | ||
<c>* Closing graphics window </c> | ||
<l>dev_close_window ()</l> | ||
</body> | ||
<docu id="main"> | ||
<parameters/> | ||
</docu> | ||
</procedure> | ||
</hdevelop> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<hdevelop file_version="1.2" halcon_version="21.11.0.0"> | ||
<procedure name="get_zivid_model_folder_name"> | ||
<interface> | ||
<ic> | ||
<par name="DeviceModelName" base_type="ctrl" dimension="0"/> | ||
</ic> | ||
<oc> | ||
<par name="ZividFolder" base_type="ctrl" dimension="0"/> | ||
</oc> | ||
</interface> | ||
<body> | ||
<l>tuple_split(DeviceModelName, ' ', Substrings)</l> | ||
<l>if (Substrings[1] == 'One')</l> | ||
<l> ZividFolder := 'zividOne'</l> | ||
<l>else</l> | ||
<l> ZividFolder := 'zividTwo'</l> | ||
<l>endif</l> | ||
<l>return ()</l> | ||
</body> | ||
<docu id="get_zivid_model_folder_name"> | ||
<parameters> | ||
<parameter id="DeviceModelName"/> | ||
<parameter id="ZividFolder"/> | ||
</parameters> | ||
</docu> | ||
</procedure> | ||
</hdevelop> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<hdevelop file_version="1.2" halcon_version="21.11.0.0"> | ||
<procedure name="read_zivid_json_params"> | ||
<interface> | ||
<ic> | ||
<par name="AcqHandle" base_type="ctrl" dimension="0"/> | ||
<par name="path" base_type="ctrl" dimension="0"/> | ||
</ic> | ||
</interface> | ||
<body> | ||
<l>get_dict_tuple (path, 'Settings', Settings)</l> | ||
<l>get_dict_tuple (Settings,'Acquisitions', Acquisitions)</l> | ||
<l>get_dict_param (Acquisitions, 'keys', [], AllKeys)</l> | ||
<c/> | ||
<c>* Single Capture or HDR</c> | ||
<l>if (|AllKeys|==1)</l> | ||
<l> set_framegrabber_param (AcqHandle, 'AcquisitionMode', 'SingleFrame')</l> | ||
<l>elseif (|AllKeys| > 1)</l> | ||
<l> set_framegrabber_param (AcqHandle, 'AcquisitionMode', 'MultiAcquisitionFrame')</l> | ||
<l>endif</l> | ||
<c/> | ||
<c>* Acquisition Settings</c> | ||
<l>for Index := 0 to |AllKeys| -1 by 1</l> | ||
<l> get_dict_tuple (Acquisitions, Index, AcquisitionIndex)</l> | ||
<l> get_dict_tuple (AcquisitionIndex, 'Acquisition', Acquisition)</l> | ||
<l> get_dict_tuple (Acquisition, 'ExposureTime', ExposureTime)</l> | ||
<l> set_framegrabber_param(AcqHandle,'ExposureTime', ExposureTime)</l> | ||
<l> get_dict_tuple (Acquisition, 'Aperture', Aperture)</l> | ||
<l> set_framegrabber_param (AcqHandle, 'Aperture', Aperture)</l> | ||
<l> get_dict_tuple(Acquisition, 'Brightness', Brightness) </l> | ||
<l> set_framegrabber_param (AcqHandle, 'Brightness', Brightness)</l> | ||
<l> get_dict_tuple(Acquisition, 'Gain', Gain) </l> | ||
<l> set_framegrabber_param(AcqHandle, 'Gain', Gain)</l> | ||
<l> set_framegrabber_param(AcqHandle, 'AddAcquisition',1)</l> | ||
<l>endfor</l> | ||
<c/> | ||
<c>* Processing Settings</c> | ||
<l>get_dict_tuple(Settings, 'Processing', Processing)</l> | ||
<l>get_dict_tuple(Processing, 'Filters', Filters)</l> | ||
<c/> | ||
<c>* Noise Filter</c> | ||
<l>get_dict_tuple(Filters, 'Noise', Noise)</l> | ||
<l>get_dict_tuple(Noise, 'Removal', Removal)</l> | ||
<l>get_dict_tuple(Removal,'Enabled',Enabled)</l> | ||
<l>set_framegrabber_param(AcqHandle,'ProcessingFiltersNoiseRemovalEnabled', Enabled)</l> | ||
<l>get_dict_tuple(Removal,'Threshold',Threshold)</l> | ||
<l>set_framegrabber_param(AcqHandle,'ProcessingFiltersNoiseRemovalThreshold',Threshold)</l> | ||
<c/> | ||
<c>* Outlier Filter</c> | ||
<l>get_dict_tuple(Filters, 'Outlier', Outlier)</l> | ||
<l>get_dict_tuple(Outlier, 'Removal', Removal) </l> | ||
<l>get_dict_tuple(Removal,'Enabled', Enabled)</l> | ||
<l>set_framegrabber_param(AcqHandle,'ProcessingFiltersOutlierRemovalEnabled', Enabled)</l> | ||
<l>get_dict_tuple(Removal,'Threshold', Threshold)</l> | ||
<l>set_framegrabber_param (AcqHandle, 'ProcessingFiltersOutlierRemovalThreshold', Threshold)</l> | ||
<c/> | ||
<c>* Reflection Filter</c> | ||
<l>get_dict_tuple(Filters, 'Reflection', Reflection)</l> | ||
<l>get_dict_tuple(Reflection, 'Removal', Removal)</l> | ||
<l>get_dict_tuple(Removal, 'Enabled', Enabled) </l> | ||
<l>set_framegrabber_param (AcqHandle, 'ProcessingFiltersReflectionRemovalEnabled',Enabled)</l> | ||
<l>get_dict_tuple(Removal,'Experimental', Experimental)</l> | ||
<l>get_dict_tuple(Experimental,'Mode', Mode)</l> | ||
<l>set_framegrabber_param(AcqHandle, 'ProcessingFiltersReflectionRemovalExperimentalMode',Mode)</l> | ||
<c/> | ||
<c>* Smoothing Filter</c> | ||
<l>get_dict_tuple(Filters, 'Smoothing', Smoothing)</l> | ||
<l>get_dict_tuple(Smoothing, 'Gaussian', Gaussian)</l> | ||
<l>get_dict_tuple(Gaussian, 'Enabled', Enabled)</l> | ||
<l>set_framegrabber_param(AcqHandle, 'ProcessingFiltersSmoothingGaussianEnabled',Enabled)</l> | ||
<l>get_dict_tuple(Gaussian, 'Sigma', Sigma)</l> | ||
<l>set_framegrabber_param(AcqHandle, 'ProcessingFiltersSmoothingGaussianSigma', Sigma)</l> | ||
<c/> | ||
<c>* ContrastDistortion Filter</c> | ||
<l>get_dict_tuple(Filters, 'Experimental', Experimental)</l> | ||
<l>get_dict_tuple(Experimental, 'ContrastDistortion', ContrastDistortion)</l> | ||
<l>get_dict_tuple(ContrastDistortion, 'Correction', Correction)</l> | ||
<l>get_dict_tuple(Correction, 'Enabled', Enabled)</l> | ||
<l>get_dict_tuple(Correction, 'Strength', Strength)</l> | ||
<l>set_framegrabber_param(AcqHandle, 'ProcessingFiltersExperimentalContrastDistortionCorrectionEnabled',Enabled)</l> | ||
<l>set_framegrabber_param(AcqHandle, 'ProcessingFiltersExperimentalContrastDistortionCorrectionStrength',Strength)</l> | ||
<l>get_dict_tuple(ContrastDistortion, 'Removal', Removal)</l> | ||
<l>get_dict_tuple(Removal, 'Enabled', Enabled)</l> | ||
<l>get_dict_tuple(Removal, 'Threshold', Threshold)</l> | ||
<l>set_framegrabber_param(AcqHandle, 'ProcessingFiltersExperimentalContrastDistortionRemovalEnabled',Enabled)</l> | ||
<l>set_framegrabber_param(AcqHandle, 'ProcessingFiltersExperimentalContrastDistortionRemovalThreshold',Threshold)</l> | ||
<c/> | ||
<c>* Color Settings</c> | ||
<l>get_dict_tuple(Processing, 'Color', Color)</l> | ||
<l>get_dict_tuple(Color, 'Balance', Balance)</l> | ||
<l>get_dict_tuple(Balance, 'Blue', Blue)</l> | ||
<l>get_dict_tuple(Balance, 'Green', Green)</l> | ||
<l>get_dict_tuple(Balance, 'Red', Red)</l> | ||
<l>set_framegrabber_param (AcqHandle,'ProcessingColorBalanceBlue', Blue)</l> | ||
<l>set_framegrabber_param (AcqHandle,'ProcessingColorBalanceGreen', Green)</l> | ||
<l>set_framegrabber_param (AcqHandle,'ProcessingColorBalanceRed', Red)</l> | ||
<l>get_dict_tuple(Color, 'Experimental', Experimental)</l> | ||
<l>get_dict_tuple(Experimental, 'Mode', Mode)</l> | ||
<l>set_framegrabber_param(AcqHandle, 'ProcessingColorExperimentalMode', Mode)</l> | ||
<c/> | ||
<l>return ()</l> | ||
</body> | ||
<docu id="read_zivid_json_params"> | ||
<parameters> | ||
<parameter id="AcqHandle"/> | ||
<parameter id="path"/> | ||
</parameters> | ||
</docu> | ||
</procedure> | ||
</hdevelop> |