GoWebScan API
GoWebScanUtilities.h
Go to the documentation of this file.
1 /**
2 * @file GoWebScanUtilities.h
3 * @brief Defines GoWebScan utility functions.
4 *
5 * @internal
6 * Copyright (C) 2017-2026 by LMI Technologies Inc.
7 * Licensed under the MIT License.
8 * Redistributed files must retain the above copyright notice.
9 */
10 
11 #ifndef GO_WEB_SCAN_UTILITIES_H
12 #define GO_WEB_SCAN_UTILITIES_H
13 
14 #include <GoSdk/GoSensor.h>
19 #include <kApi/Data/kArray1.h>
20 #include <kApi/Data/kArray2.h>
21 #include <kApi/Data/kArray3.h>
22 #include <kApi/Data/kImage.h>
23 #include <kApi/Data/kMath.h>
24 #include <kApi/Io/kDirectory.h>
25 
26 #include <math.h>
27 
28 #define NM_TO_MM(VALUE) (((k64f)(VALUE))/1000000.0) ///< Converts nanometers to millimeters
29 #define UM_TO_MM(VALUE) (((k64f)(VALUE))/1000.0) ///< Converts micrometers to millimeters
30 #define MM_TO_MILS(VALUE) (((k64f)(VALUE)*(1.0/0.0254))) ///< Converts millimeters to mils
31 #define MILS_TO_MM(VALUE) (((k64f)(VALUE)*0.0254)) ///< Converts mils to millimeters
32 #define B_TO_MB(VALUE) (((k64f)(VALUE))/1000000.0) ///< Converts bytes to megabytes
33 #define GO_WEB_SCAN_UTILS_LINEAR_TO_GAMMA_EXPONENT_ESTIMATE (1 / 2.2) ///< Exponent for approximate linear to gamma transfer function
34 #define GO_WEB_SCAN_UTILS_GAMMA_TO_LINEAR_EXPONENT_ESTIMATE (2.2) ///< Exponent for approximate gamma to linear transfer function
35 
36 typedef kStatus(kCall* GoWebScanUtilsSensorFx)(kPointer context, GoSensor sensor);
37 
38 /**
39 * Applies an obstruction to raw sensor profile data. The obstruction defines a mask covering a
40 * specified ROI in Z and X. Masked points are set to null.
41 *
42 * @public @memberof GoWebScanSdk
43 * @param inPoints Pointer to input profile points.
44 * @param outPoints Pointer to masked output profile points. Can reuse the input buffer.
45 * @param count Count of profile points.
46 * @param obstructions Pointer to start of obstruction buffer.
47 * @param obstructionCount Count of obstructions in buffer.
48 * @return Operation status.
49 */
50 GoWebScanFx(kStatus) GoWebScanUtils_ApplyProfileMask(const kPoint16s* inPoints, kPoint16s* outPoints, kSize count, const GoWebScanObstruction* obstructions, kSize obstructionCount);
51 
52 /**
53 * Reorients profile data to align with system coordinates in standard orientation. In standard
54 * orientation, the sensor X-axis is aligned to the system X-axis, and the sensor z-axis is
55 * opposite the system z-axis. X data is converted to system coordinates.
56 *
57 * @public @memberof GoWebScanSdk
58 * @param inPoints Pointer to input profile points.
59 * @param outPoints Pointer to reoriented profile points.
60 * @param count Count of profile points.
61 * @param xInCenter X-center of sensor in system coordinates.
62 * @param xOrientation X-orientation of sensor.
63 * @param zOrientation Z-orientation of sensor.
64 * @return Operation status.
65 * @see GoWebScanSettings_XOrientation, GoWebScanSettings_ZOrientation
66 */
67 GoWebScanFx(kStatus) GoWebScanUtils_ApplyProfileOrientation(const kPoint16s* inPoints, kPoint16s* outPoints, kSSize count, k32s xInCenter, k32s xOrientation, k32s zOrientation);
68 
69 /**
70 * Applies an offset in Z to each input profile point. These offsets typically represent a system
71 * calibration to align all sensors to a common plane.
72 *
73 * @public @memberof GoWebScanSdk
74 * @param inPoints Pointer to input profile points. Can reuse the input buffer.
75 * @param zOffsets Pointer to Z offset buffer.
76 * @param outPoints Pointer to reoriented profile points.
77 * @param count Count of profile points.
78 * @return Operation status.
79 */
80 GoWebScanFx(kStatus) GoWebScanUtils_ApplyProfileZOffset(const kPoint16s* inPoints, const k16s* zOffsets, kPoint16s* outPoints, kSSize count);
81 
82 /**
83 * Modifies profile spots that fall on the side edge of a board (edge along Y-axis) and report a
84 * different range than their neighbour. Side edge spots are modified to report the range of the
85 * adjacent spot that is on the board, giving the board edge a 90 degree angle and more accurate
86 * length instead of a curved edge.
87 *
88 * @public @memberof GoWebScanSdk
89 * @param inPoints Pointer to input profile points.
90 * @param outPoints Pointer to output profile points.
91 * @param count Count of profile points.
92 * @param extrapolationWindow Amount along X-axis to extend board.
93 * @return Operation status.
94 */
95 GoWebScanFx(kStatus) GoWebScanUtils_ExtendSideProfile(const kPoint16s* inPoints, kPoint16s* outPoints, kSSize count, kSSize extrapolationWindow);
96 
97 /**
98 * Resamples profile data in the X-axis.
99 *
100 * @public @memberof GoWebScanSdk
101 * @param style Type of interpolation to apply during resampling.
102 * @param inPoints Pointer to input profile points.
103 * @param pointCount Count of input profile points.
104 * @param outPoints Pointer to output resampled Z profiles.
105 * @param profileCount Count of output profiles.
106 * @param xStart Start location, in mils, of resampling. In system coordinates.
107 * @param xRes Desired resolution, in mils/pixel, of resampled data.
108 * @param interpolationWindow Maximum input data X-gap, in mils, to be filled in with resampled data.
109 * @param extrapolationWindow Distance, in mils, to extend resampling window around pairs of input points.
110 * @return Operation status.
111 */
112 GoWebScanFx(kStatus) GoWebScanUtils_ResampleProfileX(GoWebScanInterpolation style, const kPoint16s* inPoints, kSSize pointCount, k16s* outProfile, kSSize profileCount, k32s xStart, k32s xRes, k32s interpolationWindow, k32s extrapolationWindow);
113 
114 /**
115 * Fills gaps in input Z data. Null input Z values are filled leftmost valid point. Initial null regions
116 * are filled with rightmost valid Z value.
117 *
118 * @public @memberof GoWebScanSdk
119 * @param inProfile Pointer to input profiles.
120 * @param outProfile Pointer to output profiles. Can reuse the input buffer.
121 * @param count Count of profile values.
122 * @param defaultZValue Value to fill gaps if no valid values are found.
123 * @return Operation status.
124 */
125 GoWebScanFx(kStatus) GoWebScanUtils_FillResampledProfile(const k16s* inProfile, k16s* outProfile, kSSize count, k16s defaultZValue);
126 
127 /**
128 * Reorients vision data to align with system coordinates in standard orientation. In standard
129 * orientation, the sensor X-axis is aligned to the system X-axis, and the sensor Y-axis is
130 * opposite the system Y-axis.
131 *
132 * @public @memberof GoWebScanSdk
133 * @param in Input vision image. Type k8u (raw Bayer image).
134 * @param out Reoriented output vision image. Type k8u (raw Bayer image).
135 * @param xOrientation X-orientation of sensor.
136 * @param yOrientation Y-orientation of sensor.
137 * @return Operation status.
138 * @see GoWebScanSettings_XOrientation, GoWebScanSettings_YOrientation
139 */
140 GoWebScanFx(kStatus) GoWebScanUtils_ApplyVisionOrientation(kImage in, kImage out, k32s xOrientation, k32s yOrientation);
141 
142 /**
143  * Applies color gains to input raw Bayer image. Gains are typically determined during
144  * system calibration.
145  *
146  * @public @memberof GoWebScanSdk
147  * @param in Input vision image. Type k8u (raw Bayer image).
148  * @param out Output vision image. Type k8u (raw Bayer image).
149  * @param gains Array of gains for all 4 channels for the image. Height of array is same
150  * as input image, width is 4*input width. Type k16u.
151  * @param gainShift Bit shift of gains.
152  * @return Operation status.
153  */
154 GoWebScanFx(kStatus) GoWebScanUtils_ApplyVisionGains(kImage in, kImage out, kArray2 gains, k32s gainShift);
155 
156 /**
157  * Reorients tracheid data to align with system coordinates in standard orientation. In standard
158  * orientation, the sensor X-axis is aligned to the system X-axis, and the sensor z-axis is
159  * opposite the system z-axis. X data is converted to system coordinates.
160  *
161  * @public @memberof GoWebScanSdk
162  * @param inPoints Pointer to input tracheid points.
163  * @param outPoints Pointer to output tracheid points.
164  * @param count Number of points.
165  * @param xInCenter X-center of sensor in system coordinates.
166  * @param xOrientation X-orientation of sensor.
167  * @return Operation status.
168  * @see GoWebScanSettings_XOrientation
169  */
170 GoWebScanFx(kStatus) GoWebScanUtils_ApplyTracheidOrientation(const GoWebScanTracheidPoint* inPoints, GoWebScanTracheidPoint* outPoints, kSSize count, k32s xInCenter, k32s xOrientation);
171 
172 /**
173  * Resamples tracheid data in the X-axis.
174  *
175  * @public @memberof GoWebScanSdk
176  * @param inPoints Pointer to input tracheid points.
177  * @param pointCount Number of input points.
178  * @param outValues Pointer to output resampled tracheid values.
179  * @param valueCount Number of output values.
180  * @param xStart Start location, in mils, of resampling. In system coordinates.
181  * @param xRes Desired resolution, in mils/pixel, of resampled data.
182  * @param interpolationWindow Maximum input data X-gap, in mils, to be filled in with resampled
183  * data.
184  * @param extrapolationWindow Distance, in mils, to extend resampling window around pairs of
185  * input points.
186  * @return Operation status.
187  */
188 GoWebScanFx(kStatus) GoWebScanUtils_ResampleTracheidX(const GoWebScanTracheidPoint* inPoints, kSSize pointCount, GoWebScanTracheidValue* outValues, kSSize valueCount, k32s xStart, k32s xRes, k32s interpolationWindow, k32s extrapolationWindow);
189 
190 /**
191  * Replaces all values in a profile system tile with nulls.
192  *
193  * @public @memberof GoWebScanSdk
194  * @param systemData Profile system tile. Type k16s.
195  * @return Operation status.
196  */
197 GoWebScanFx(kStatus) GoWebScanUtils_ClearProfileSystemTile(kArray2 systemData);
198 
199 /**
200  * Replaces all values in a vision system tile with zeroes.
201  *
202  * @public @memberof GoWebScanSdk
203  * @param systemData Vision system tile. Type kRgb.
204  * @return Operation status.
205  */
206 GoWebScanFx(kStatus) GoWebScanUtils_ClearVisionSystemTile(kArray2 systemData);
207 
208 /**
209  * Replaces all values in a tracheid system tile with nulls.
210  *
211  * @public @memberof GoWebScanSdk
212  * @param systemData Tracheid system tile. Type GoWebScanTracheidValue.
213  * @return Operation status.
214  */
215 GoWebScanFx(kStatus) GoWebScanUtils_ClearTracheidSystemTile(kArray3 systemData);
216 
217 /**
218  * Copies a profile tile from an individual sensor into a system tile at a specified column.
219  *
220  * @public @memberof GoWebScanSdk
221  * @param systemData Profile system tile. Type k16s.
222  * @param childData Profile sensor tile. Type k16s.
223  * @param x0 Column index within system tile to copy child data into.
224  * @return Operation status.
225  */
226 GoWebScanFx(kStatus) GoWebScanUtils_CopyProfileChildTile(kArray2 systemData, kArray2 childData, kSSize x0);
227 
228 /**
229  * Copies a vision tile from an individual sensor into a system tile at a specified column.
230  *
231  * @public @memberof GoWebScanSdk
232  * @param systemData Vision system tile. Type kRgb.
233  * @param childData Vision sensor tile. Type kRgb.
234  * @param x0 Column index within system tile to copy child data into.
235  * @return Operation status.
236  */
237 GoWebScanFx(kStatus) GoWebScanUtils_CopyVisionChildTile(kArray2 systemData, kArray2 childData, kSSize x0);
238 
239 /**
240  * Copies a tracheid tile from an individual sensor into a system tile at a specified column.
241  *
242  * @public @memberof GoWebScanSdk
243  * @param systemData Tracheid system tile. Type GoWebScanTracheidValue.
244  * @param childData Tracheid sensor tile. Type GoWebScanTracheidValue.
245  * @param x0 Column index within system tile to copy child data into.
246  * @return Operation status.
247  */
248 GoWebScanFx(kStatus) GoWebScanUtils_CopyTracheidChildTile(kArray3 systemData, kArray3 childData, kSSize x0);
249 
250 /**
251  * Copies two sensors' profile tiles into the system tile and blends the overlap in X. Data is
252  * blended by a weighted average.
253  *
254  * @public @memberof GoWebScanSdk
255  * @param systemData Profile system tile. Type k16s.
256  * @param childData0 First profile sensor tile. Type k16s.
257  * @param childData1 Second profile sensor tile. Type k16s.
258  * @param x0 Column index within system tile to copy first profile sensor tile into.
259  * @param x1 Column index within system tile to copy second profile sensor tile into.
260  * @return Operation status.
261  */
262 GoWebScanFx(kStatus) GoWebScanUtils_BlendProfileChildOverlap(kArray2 systemData, kArray2 childData0, kArray2 childData1, kSSize x0, kSSize x1);
263 
264 /**
265  * Copies two sensors' vision tiles into the system tile and blends the overlap in X. Data is
266  * blended by a weighted average.
267  *
268  * @public @memberof GoWebScanSdk
269  * @param systemData Vision system tile. Type kRgb.
270  * @param childData0 First vision sensor tile. Type kRgb.
271  * @param childData1 Second vision sensor tile. Type kRgb.
272  * @param x0 Column index within system tile to copy first vision sensor tile into.
273  * @param x1 Column index within system tile to copy second vision sensor tile into.
274  * @return Operation status.
275  */
276 GoWebScanFx(kStatus) GoWebScanUtils_BlendVisionChildOverlap(kArray2 systemData, kArray2 childData0, kArray2 childData1, kSSize x0, kSSize x1);
277 
278 /**
279 * Copies two sensors' tracheid tiles into the system tile and blends the overlap in X. Data is
280 * blended by a weighted average.
281 *
282 * @public @memberof GoWebScanSdk
283 * @param systemData Tracheid system tile. Type GoWebScanTracheidValue.
284 * @param childData0 First tracheid sensor tile. Type GoWebScanTracheidValue.
285 * @param childData1 Second tracheid sensor tile. Type GoWebScanTracheidValue.
286 * @param x0 Column index within system tile to copy first tracheid sensor tile into.
287 * @param x1 Column index within system tile to copy second tracheid sensor tile into.
288 * @return Operation status.
289 */
290 GoWebScanFx(kStatus) GoWebScanUtils_BlendTracheidChildOverlap(kArray3 systemData, kArray3 childData0, kArray3 childData1, kSSize x0, kSSize x1);
291 
292 /**
293  * Copies two sensors' profile tiles into the system tile and fills the gap in X. Data is filled
294  * with interpolated data.
295  *
296  * @public @memberof GoWebScanSdk
297  * @param systemData Profile system tile. Type k16s.
298  * @param childData0 First profile sensor tile. Type k16s.
299  * @param childData1 Second profile sensor tile. Type k16s.
300  * @param x0 Column index within system tile to copy first profile sensor tile
301  * into.
302  * @param x1 Column index within system tile to copy second profile sensor tile
303  * into.
304  * @param gapSearchWindow Gaps are processed by searching for the last valid left element and
305  * first valid right element within the gap search window.
306  * @param interpolation Type of interpolation to use to fill gap.
307  * @return Operation status.
308  */
309 GoWebScanFx(kStatus) GoWebScanUtils_FillProfileChildGap(kArray2 systemData, kArray2 childData0, kArray2 childData1, kSSize x0, kSSize x1, k32s gapSearchWindow, GoWebScanInterpolation interpolation);
310 
311 /**
312 * Copies two sensors' vision tiles into the system tile and fills the gap in X. Data is filled
313 * with the nearest neighbour's value.
314 *
315 * @public @memberof GoWebScanSdk
316 * @param systemData Vision system tile. Type kRgb.
317 * @param childData0 First vision sensor tile. Type kRgb.
318 * @param childData1 Second vision sensor tile. Type kRgb.
319 * @param x0 Column index within system tile to copy first vision sensor tile
320 * into.
321 * @param x1 Column index within system tile to copy second vision sensor tile
322 * into.
323 * @param gapSearchWindow Gaps are processed by searching for the last valid left element and
324 * first valid right element within the gap search window.
325 * @return Operation status.
326 */
327 GoWebScanFx(kStatus) GoWebScanUtils_FillVisionChildGap(kArray2 systemData, kArray2 childData0, kArray2 childData1, kSSize x0, kSSize x1, k32s gapSearchWindow);
328 
329 /**
330 * Copies two sensors' tracheid tiles into the system tile and fills the gap in X. Data is filled
331 * with the nearest neighbour's value.
332 *
333 * @public @memberof GoWebScanSdk
334 * @param systemData Tracheid system tile. Type GoWebScanTracheidValue.
335 * @param childData0 First tracheid sensor tile. Type GoWebScanTracheidValue.
336 * @param childData1 Second tracheid sensor tile. Type GoWebScanTracheidValue.
337 * @param x0 Column index within system tile to copy first tracheid sensor tile
338 * into.
339 * @param x1 Column index within system tile to copy second tracheid sensor tile
340 * into.
341 * @param gapSearchWindow Gaps are processed by searching for the last valid left element and
342 * first valid right element within the gap search window.
343 * @return Operation status.
344 */
345 GoWebScanFx(kStatus) GoWebScanUtils_FillTracheidChildGap(kArray3 systemData, kArray3 childData0, kArray3 childData1, kSSize x0, kSSize x1, k32s gapSearchWindow);
346 
347 /**
348  * Determines presence information from input profiles and adds to existing presence
349  * information. Presence is defined as true when a profile is non-null, false otherwise.
350  *
351  * @public @memberof GoWebScanSdk
352  * @param presenceData Pointer to input profile buffer.
353  * @param presenceTest Pointer to output presence buffer. Can contain existing presence
354  * information, otherwise all values should be set to 0.
355  * @param count Number of profiles.
356  * @return Operation status.
357  */
358 GoWebScanFx(kStatus) GoWebScanUtils_AddPresenceData(const k16s* presenceData, kBool* presenceTest, kSSize count);
359 
360 /**
361  * Determines if an object is detected in a row of input presence data. An object is defined as
362  * having a true presence count greater than the trigger threshold. The true presence values can
363  * either be located anywhere in the row (global detection style) or must be contiguous (local
364  * detection style).
365  *
366  * @public @memberof GoWebScanSdk
367  * @param presenceTest Pointer to input presence buffer.
368  * @param count Number of presence values.
369  * @param detectionStyle The board detection style.
370  * @param triggerThreshold Minimum number of true presence data to trigger if an object is
371  * detected.
372  * @param isDetected Receives a boolean representing if an object was found in the
373  * data.
374  * @return Operation status.
375  */
376 GoWebScanFx(kStatus) GoWebScanUtils_DetectObject(const kBool* presenceTest, kSSize count, GoWebScanDetectionStyle detectionStyle, k32s triggerThreshold, kBool* isDetected);
377 
378 /**
379  * Extracts a requested section from a profile system tile (representing merged and resampled
380  * data from an entire plane of the system). The section is represented by a start column
381  * (ceil(system x0 / xRes)). The output section array should be initialized to be the section
382  * width (ceil((x1 - x0) / xRes)) and have a height matching the input profile system tile.
383  *
384  * @public @memberof GoWebScanSdk
385  * @param tile Input profile system tile's data array. Type k16s.
386  * @param section Output data array representing requested section. Array should be
387  * constructed and initialized to the expected section width (width of
388  * section in mils divided by X resolution) and expected section height
389  * (same height as the profile system tile). Type k16s.
390  * @param tileX0 The profile system tile's start column. Can be determined from
391  * GoWebScanConfig_XStartPix.
392  * @param sectionX0 The section's start column. Can be determined by the section x0 in
393  * GoWebScanSettings divided by the X resolution.
394  * @param nullValue Null value to fill data with if the section falls outside the system
395  * tile's X field of view.
396  * @return Operation status.
397  */
398 GoWebScanFx(kStatus) GoWebScanUtils_ProfileTileToSection(kArray2 tile, kArray2 section, kSSize tileX0, kSSize sectionX0, k16s nullValue);
399 
400 /**
401 * Extracts a requested section from a vision system tile (representing merged and resampled
402 * data from an entire plane of the system). The section is represented by a start column
403 * (ceil(system x0 / xRes)). The output section array should be initialized to be the section
404 * width (ceil((x1 - x0) / xRes)) and have a height matching the input vision system tile.
405 *
406 * @public @memberof GoWebScanSdk
407 * @param tile Input vision system tile's data array. Type kRgb.
408 * @param section Output data array representing requested section. Array should be
409 * constructed and initialized to the expected section width (width of
410 * section in mils divided by X resolution) and expected section height
411 * (same height as the profile system tile). Type kRgb.
412 * @param tileX0 The vision system tile's start column. Can be determined from
413 * GoWebScanConfig_XStartPix.
414 * @param sectionX0 The section's start column. Can be determined by the section x0 in
415 * GoWebScanSettings divided by the X resolution.
416 * @param nullValue Null value to fill data with if the section falls outside the system
417 * tile's X field of view.
418 * @return Operation status.
419 */
420 GoWebScanFx(kStatus) GoWebScanUtils_VisionTileToSection(kArray2 tile, kArray2 section, kSSize tileX0, kSSize sectionX0, kRgb nullValue);
421 
422 /**
423  * Extracts a requested section from a tracheid system tile (representing merged and resampled
424  * data from an entire plane of the system). The section is represented by a start column
425  * (ceil(system x0 / xRes)). The output section array should be initialized to be the section
426  * width (ceil((x1 - x0) / xRes)) and have a height matching the input vision system tile.
427  *
428  * @public @memberof GoWebScanSdk
429  * @param tile Input tracheid system tile's data array. Type GoWebScanTracheidValue.
430  * @param angleSection Output angle array representing requested section. Output arrays
431  * should be constructed and initialized to the expected section width
432  * (width of section in mils divided by X resolution) and expected
433  * section height (same height as the profile system tile). Type k8u.
434  * @param scatterSection Output scatter array representing requested section. Type k8u.
435  * @param areaSection Output area array representing requested section. Type k8u.
436  * @param tileX0 The vision system tile's start column. Can be determined from
437  * GoWebScanConfig_XStartPix.
438  * @param sectionX0 The section's start column. Can be determined by the section x0 in
439  * GoWebScanSettings divided by the X resolution.
440  * @return Operation status.
441  */
442 GoWebScanFx(kStatus) GoWebScanUtils_TracheidTileToSection(kArray3 tile, kArray2 angleSection, kArray2 scatterSection, kArray2 areaSection, kSSize tileX0, kSSize sectionX0);
443 
444 /**
445  * Determines the new Bayer color filter array pattern if the input data undergoes an X and Y
446  * orientation change.
447  *
448  * @public @memberof GoWebScanSdk
449  * @param cfa Original color filter array type.
450  * @param xOrientation The sensor X-orientation.
451  * @param yOrientation The sensor Y-orientation.
452  * @return New color filter array type.
453  * @see GoWebScanSettings_XOrientation, GoWebScanSettings_YOrientation
454  */
455 GoWebScanFx(kCfa) GoWebScanUtils_ReorientCfa(kCfa cfa, k32s xOrientation, k32s yOrientation);
456 
457 /* Calibration utilities */
458 
459 /**
460  * Returns Bayer cell indexes for each color channel based on color filter array type.
461  *
462  * @public @memberof GoWebScanSdk
463  * @param cfa Color filter array type.
464  * @param red Receives the red index.
465  * @param greenR Receives the green-red index.
466  * @param greenB Receives the green-blue index.
467  * @param blue Receives the blue index.
468  * @return Operation status.
469  */
470 GoWebScanFx(kStatus) GoWebScanUtils_BayerCellToIndices(kCfa cfa, kSSize* red, kSSize* greenR, kSSize* greenB, kSSize* blue);
471 
472 /**
473  * Maps an RGB pixel's channels to a Bayer cell given the color filter array type.
474  *
475  * @public @memberof GoWebScanSdk
476  * @param cfa Color filter array type.
477  * @param pixel Input RGB pixel.
478  * @param values Pointer to output Bayer cell buffer.
479  * @return Operation status.
480  */
481 GoWebScanFx(kStatus) GoWebScanUtils_RgbToBayerCell(kCfa cfa, kRgb pixel, k32s* values);
482 
483 /**
484  * Linearly scales values from an input array to an output array of a different width.
485  *
486  * @public @memberof GoWebScanSdk
487  * @param in Input array of 32s values.
488  * @param out Output array of 32s values. Function will handle reallocating the array to the
489  * specified outWidth.
490  * @param outWidth Width of the output array.
491  * @return Operation status.
492  */
493 GoWebScanFx(kStatus) GoWebScanUtils_SampleYValues(kArray1 in, kArray1 out, kSSize outWidth);
494 
495 /**
496  * Linearly scales gain coefficients from an input array to an output array of a different
497  * height and width.
498  *
499  * @public @memberof GoWebScanSdk
500  * @param in Input array of gain coefficients. Type k64f.
501  * @param out Output array of scaled gain coefficients. Function will handle
502  * reallocating the array to the specified outWidth and outHeight. Type k64f.
503  * @param outWidth Width of the output array.
504  * @param outHeight Height of the output array.
505  * @param alloc Memory allocator (or kNULL for default).
506  * @return Operation status.
507  */
508 GoWebScanFx(kStatus) GoWebScanUtils_SampleGainCoefficientsChannel(kArray2 in, kArray2 out, kSSize outWidth, kSSize outHeight, kAlloc alloc);
509 
510 /**
511  * Merges individual color channel gains into a Bayer pattern gain array.
512  *
513  * @public @memberof GoWebScanSdk
514  * @param cfa Color filter array type of the output Bayer gain array.
515  * @param red Input array of red gains. Same width and height as other input gains. Type
516  * k64f.
517  * @param green Input array of green gains. Same width and height as other input gains. Type
518  * k64f.
519  * @param blue Input array of blue gains. Same width and height as other input gains. Type
520  * k64f.
521  * @param merged Output array of merged gains. Will be reallocated to 2x width and height of
522  * input gains (due to Bayer pattern). Type k64f.
523  * @return Operation status.
524  */
525 GoWebScanFx(kStatus) GoWebScanUtils_MergeGainCoefficientChannels(kCfa cfa, kArray2 red, kArray2 green, kArray2 blue, kArray2 merged);
526 
527 /**
528  * Converts floating point gains to 16-bit unsigned gains scaled by 1 &lt;&lt;
529  * GO_WEB_SCAN_FLATFIELD_RES_BITS.
530  *
531  * @public @memberof GoWebScanSdk
532  * @param in Input floating point gains. Type k64f.
533  * @param out Output scaled integer gains. Type k16u.
534  * @return Operation status.
535  */
536 GoWebScanFx(kStatus) GoWebScanUtils_ScaleGainImage(kArray2 in, kArray2 out);
537 
538 /**
539  * Calculates count of non-null points.
540  *
541  * @public @memberof GoWebScanSdk
542  * @param points Pointer to start of points buffer.
543  * @param pointCount Number of points.
544  * @param validCount Receives the count of non-null points.
545  * @return Operation status.
546  */
547 GoWebScanFx(kStatus) GoWebScanUtils_CountValidPoints(const kPoint16s* points, kSize pointCount, kSize* validCount);
548 
549 /**
550  * Calculates recommended profile transmit limit for given settings and profile sensor.
551  *
552  * @public @memberof GoWebScanSdk
553  * @param settings GoWebScan settings.
554  * @param profileSensor Profile sensor.
555  * @param profileTransmitLimit Receives the recommended profile transmit limit.
556  * @return Operation status.
557  */
558 GoWebScanFx(kStatus) GoWebScanUtils_CalculateProfileTransmitLimit(GoWebScanSettings settings, GoSensor profileSensor, k32u* profileTransmitLimit);
559 
560 /**
561  * Calculates recommended vision transmit limit for given settings and vision sensor.
562  *
563  * @public @memberof GoWebScanSdk
564  * @param settings GoWebScan settings.
565  * @param visionSensor Vision sensor.
566  * @param visionTransmitLimit Receives the recommended vision transmit limit.
567  * @return Operation status.
568  */
569 GoWebScanFx(kStatus) GoWebScanUtils_CalculateVisionTransmitLimit(GoWebScanSettings settings, GoSensor visionSensor, k32u* visionTransmitLimit);
570 
571 /**
572  * Calculate the vision delay shift to avoid interference with profile exposures.
573  *
574  * @public @memberof GoWebScanSdk
575  * @param settings GoWebScanSettings settings.
576  * @return Vision delay shift.
577  */
578 GoWebScanFx(k32u) GoWebScanUtils_CalculateVisionDelayShift(GoWebScanSettings settings);
579 
580 /**
581  * Verifies that the system timing setup does not result in interference between sensors.
582  *
583  * @public @memberof GoWebScanSdk
584  * @param settings GoWebScanSettings settings.
585  * @param errorMsg Error message output if error occurs.
586  * @param length Error message buffer length.
587  * @return Operation status.
588  */
589 GoWebScanFx(kStatus) GoWebScanUtils_VerifySystemTiming(GoWebScanSettings settings, kChar* errorMsg, kSize length);
590 
591 /**
592  * Aligns the individual X and Y references of multiple stations' calibrations to a common global X and Y
593  * reference. This is done by calculating the overall X and Y bias, which is the average of the X and Y
594  * references from all servers, then setting the calibration X and Y adjustment to the bias minus the reference.
595  * The list index of each calibration and settings object corresponds to the server index.
596  *
597  * @public @memberof GoWebScanSdk
598  * @param calibrationPtr Pointer to start address of GoWebScanCal object list.
599  * @param settingsPtr Pointer to start address of GoWebScanSettings object list.
600  * @param count Length of lists.
601  * @return Operation status.
602  */
603 GoWebScanFx(kStatus) GoWebScanUtils_AlignCalibrations(const GoWebScanCal* calibrationPtr, const GoWebScanSettings* settingsPtr, kSize count);
604 
605  /**
606  * Helper function to store kArrayList of sensor info items to a specified folder path.
607  *
608  * @public @memberof GoWebScanSdk
609  * @param sensorInfo kArrayList of GoWebScanConfigSensorInfo items.
610  * @param folderName Folder path to store sensor info.
611  * @return Operation status.
612  */
613 GoWebScanFx(kStatus) GoWebScanUtils_StoreSensorInfo(kArrayList sensorInfo, const kChar* folderName);
614 
615 /**
616  * Helper function to confirm specified folder path contains all expected sensor info files, or otherwise
617  * specify the first one that is missing.
618  *
619  * @public @memberof GoWebScanSdk
620  * @param settings Settings specifying what sensors are expected to have info.
621  * @param folderName Folder path containing sensor info.
622  * @param missingFileName Pointer to kChar array which will be set to name of first missing file, if any.
623  * @param missingFileNameLen Length of missingFileName array.
624  * @return Operation status.
625  */
626 GoWebScanFx(kBool) GoWebScanUtils_SensorInfoFilesExist(GoWebScanSettings settings, const kChar* folderName, kChar* missingFileName, kSize missingFileNameLen);
627 
628 /**
629  * Helper function to load kArrayList of sensor info items items from a specified folder path.
630  *
631  * @public @memberof GoWebScanSdk
632  * @param sensorInfo Pointer to be populated with kArrayList of GoWebScanConfigSensorInfo items.
633  * @param settings Settings specifying what sensors are expected to have info.
634  * @param folderName Folder path containing sensor info.
635  * @return Operation status.
636  */
637 GoWebScanFx(kStatus) GoWebScanUtils_LoadSensorInfo(kArrayList* sensorInfo, GoWebScanSettings settings, const kChar* folderName);
638 
639 /**
640  * Helper function to call a function on multiple GoSensor objects asynchronously.
641  *
642  * @public @memberof GoWebScanSdk
643  * @param function Function to call on each GoSensor object.
644  * @param context Receiver argument for callback, in addition to the GoSensor object.
645  * @param sensors Pointer to array of GoSensor objects.
646  * @param count Count of GoSensor objects.
647  * @return Operation status.
648  */
649 GoWebScanFx(kStatus) GoWebScanUtils_AsyncSensorFunction(GoWebScanUtilsSensorFx function, kPointer context, GoSensor* sensors, kSize count);
650 
651 /**
652  * Converts a kImage to a kArray2.
653  *
654  * @public @memberof GoWebScanSdk
655  * @param input Input image.
656  * @param output Pointer to be populated with output kArray2.
657  * @param alloc Memory allocator (or kNULL for default).
658  * @return Operation status.
659  */
660 GoWebScanFx(kStatus) GoWebScanUtils_ImageToArray2(kImage input, kArray2* output, kAlloc alloc);
661 
662 /**
663  * Converts a kArray2 to a kImage.
664  *
665  * @public @memberof GoWebScanSdk
666  * @param input Input kArray2.
667  * @param output Pointer to be populated with output kImage.
668  * @param alloc Memory allocator (or kNULL for default).
669  * @return Operation status.
670  */
671 GoWebScanFx(kStatus) GoWebScanUtils_Array2ToImage(kArray2 input, kImage* output, kAlloc alloc);
672 
673 /**
674  * Converts k8u values to k64f.
675  *
676  * @public @memberof GoWebScanSdk
677  * @param input Pointer to input k8u values.
678  * @param output Pointer to output k64f values.
679  * @param count Number of elements to convert.
680  * @return Operation status.
681  */
682 GoWebScanFx(kStatus) GoWebScanUtils_8uTo64f(const k8u* input, k64f* output, kSize count);
683 
684 /**
685  * Clamps, rounds, and converts k64f values to k8u.
686  *
687  * @public @memberof GoWebScanSdk
688  * @param input Pointer to input k64f values.
689  * @param output Pointer to output k8u values.
690  * @param count Number of elements to convert.
691  * @return Operation status.
692  */
693 GoWebScanFx(kStatus) GoWebScanUtils_Round64fTo8u(const k64f* input, k8u* output, kSize count);
694 
695 /**
696  * Converts kRgb values to kPoint3d64f, where r, g, and b respectively become x, y, and z.
697  *
698  * @public @memberof GoWebScanSdk
699  * @param input Pointer to input kRgb values.
700  * @param output Pointer to output kPoint3d64f values.
701  * @param count Number of elements to convert.
702  * @return Operation status.
703  */
704 GoWebScanFx(kStatus) GoWebScanUtils_RgbToPoint3d64f(const kRgb* input, kPoint3d64f* output, kSize count);
705 
706 /**
707  * Converts kPoint3d64f values to kRgb, where x, y, and z respectively become r, g, and b
708  * by clamping, rounding, and converting to k8u.
709  *
710  * @public @memberof GoWebScanSdk
711  * @param input Pointer to input kPoint3d64f values.
712  * @param output Pointer to output kRgb values.
713  * @param count Number of elements to convert.
714  * @return Operation status.
715  */
716 GoWebScanFx(kStatus) GoWebScanUtils_RoundPoint3d64fToRgb(const kPoint3d64f* input, kRgb* output, kSize count);
717 
718 /**
719  * Multiplies each element in an array of k64f values by a scalar.
720  *
721  * @public @memberof GoWebScanSdk
722  * @param input Pointer to input array of k64f values.
723  * @param output Pointer to output array of k64f values.
724  * @param count Number of elements in the array.
725  * @param scale Scalar value to multiply each element by.
726  * @return Operation status.
727  */
728 GoWebScanFx(kStatus) GoWebScanUtils_Scale64f(const k64f* input, k64f* output, kSize count, k64f scale);
729 
730 /**
731  * Scales an array of 3D points by the given scale factors.
732  *
733  * @public @memberof GoWebScanSdk
734  * @param input Pointer to input array of kPoint3d64f values.
735  * @param output Pointer to output array of kPoint3d64f values.
736  * @param count Number of points in the array.
737  * @param scale Pointer to kPoint3d64f containing scale factors (x, y, z).
738  * @return Operation status.
739  */
740 GoWebScanFx(kStatus) GoWebScanUtils_ScalePoint3d64f(const kPoint3d64f* input, kPoint3d64f* output, kSize count, const kPoint3d64f* scale);
741 
742 /**
743  * Raises each element in an array of k64f values to a power using the pow() function.
744  *
745  * @public @memberof GoWebScanSdk
746  * @param input Pointer to input array of k64f values.
747  * @param output Pointer to output array of k64f values.
748  * @param count Number of elements in the array.
749  * @param exponent Exponent to raise each element to.
750  * @return Operation status.
751  */
752 GoWebScanFx(kStatus) GoWebScanUtils_ApplyExponentTo64f(const k64f* input, k64f* output, kSize count, k64f exponent);
753 
754 /**
755  * Raises each component of every kPoint3d64f in an array to a per-component power using the pow() function.
756  *
757  * @public @memberof GoWebScanSdk
758  * @param input Pointer to input array of kPoint3d64f values.
759  * @param output Pointer to output array of kPoint3d64f values.
760  * @param count Number of points in the array.
761  * @param exponent Per-component exponents (x, y, z applied to input x, y, z respectively).
762  * @return Operation status.
763  */
764 GoWebScanFx(kStatus) GoWebScanUtils_ApplyExponentToPoint3d64f(const kPoint3d64f* input, kPoint3d64f* output, kSize count, kPoint3d64f exponent);
765 
766 /**
767  * Constructs a gamma correction lookup table in which the value at an index is calculated by normalizing the index (from 0-255 to 0-1),
768  * applying the given exponent, and converting back to k8u.
769  *
770  * @public @memberof GoWebScanSdk
771  * @param output Pointer to receive the newly constructed kArray1 of k8u lookup values.
772  * @param gamma Gamma exponent to apply.
773  * @param alloc Memory allocator (or kNULL for default).
774  * @return Operation status.
775  */
776 GoWebScanFx(kStatus) GoWebScanUtils_PopulateGammaLookup(kArray1* output, k64f gamma, kAlloc alloc);
777 
778 /**
779  * Applies a precomputed gamma lookup table to an array of kRgb pixels.
780  * Each R, G, and B channel is independently remapped through the lookup table.
781  *
782  * @public @memberof GoWebScanSdk
783  * @param input Pointer to input kRgb pixels.
784  * @param output Pointer to output kRgb pixels.
785  * @param count Number of pixels.
786  * @param gammaLookup kArray1 of k8u containing the gamma lookup table (must have > k8U_MAX entries).
787  * @return Operation status.
788  */
789 GoWebScanFx(kStatus) GoWebScanUtils_ApplyGammaLookup(const kRgb* input, kRgb* output, kSize count, kArray1 gammaLookup);
790 
791 #include <GoWebScanSdk/GoWebScanUtilities.x.h>
792 
793 #endif
Represents a tracheid point, which is the integer tracheid data for a spot with the X position (mils)...
Definition: GoWebScanSdkDef.h:558
Represents a style of triggering the start of an object when in detection mode. The start of an objec...
Represents a style of interpolation used during profile resampling.
Represents a container for user-configurable settings of the system. The class reads and writes the s...
Essential GoWebScan declarations.
Represents integer values of the spot tracheid data. These values are calculated from the spot shape...
Definition: GoWebScanSdkDef.h:542
Declares a GoWebScanCal object.
Declares a GoWebScanProcess object.
Represents a container for the system calibration. The system calibration corrects for mounting diffe...
Represents a user-defined obstruction to ignore a zone in X and Z in the input profile data...
Definition: GoWebScanSdkDef.h:589
Declares a GoWebScanConfig object.