<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.advacam.cz/index.php?action=history&amp;feed=atom&amp;title=Beam_hardening_correction%3A_Bath_example</id>
	<title>Beam hardening correction: Bath example - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.advacam.cz/index.php?action=history&amp;feed=atom&amp;title=Beam_hardening_correction%3A_Bath_example"/>
	<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Beam_hardening_correction:_Bath_example&amp;action=history"/>
	<updated>2026-04-21T09:59:43Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Beam_hardening_correction:_Bath_example&amp;diff=476&amp;oldid=prev</id>
		<title>HudecekP: /* Code */</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Beam_hardening_correction:_Bath_example&amp;diff=476&amp;oldid=prev"/>
		<updated>2023-07-17T11:18:53Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Code&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 13:18, 17 July 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;= Introduction =&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;This example using the config file named config.txt to configure steps of the process. File contents is like this:&amp;lt;br&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;syntaxhighlight&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;o, First: line type: o - comment, r - referrence plate, m - measuring&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;o, Ref. cfg. line: r, thickness [mm], acqTime [s], num of expositions, output files: d data / p picture / b both / n none, name&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;r, 0, 0.005, 200, d, dir_beam&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;r, 1, 0.006, 200, d, ref_1&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;r, 2, 0.010, 200, d, ref_2&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;r, 3, 0.015, 200, d, ref_3&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;o, Measuring cfg. line: m, acqTime [s], num of expositions, bad px setting: d device / b BH system, output files: d data / p picture / b both / n none, name&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;m, 0.005, 200, d, b, test1&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;m, 0.005, 200, d, b, test2&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;m, 0.01, 200, b, b, test3&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;m, 0.02, 200, b, b, test4&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/syntaxhighlight&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;The example program read the line, display it in the console, will ask if it should do it and wait for user response. If yes, program acquire required number of frames, view simple histogram in the console, do the processing and save images, if reqired.&amp;lt;br&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;br&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;This example is using many auxiliary functions. Complete code is in the example project named MiniPixTpx3-Thickness-bath. To get usable acquisition times do a experimental exposures in the Pixet program, or get them using a second sample project named MiniPixTpx3-Thickness-auto that has auto-tuning and image preview in the console.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Code =&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Code =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki3:diff::1.12:old-475:rev-476 --&gt;
&lt;/table&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Beam_hardening_correction:_Bath_example&amp;diff=475&amp;oldid=prev</id>
		<title>HudecekP: Created page with &quot;   = Code = &lt;syntaxhighlight lang=&quot;C&quot; line&gt; /**  * Copyright (C) 2021 ADVACAM  * @author     Pavel Hudecek &lt;pavel.hudecek@advacam.com&gt;  *   * Example of thickness measuring with beam hardening compensation feature  *  B - Bath version  */  /* Used API functions:  pxcGetLastError pxcInitialize pxcGetDevicesCount pxcGetDeviceName pxcGetDeviceChipID  pxcSetTimepix3Mode  pxcMeasureSingleFrameTpx3 pxcGetMeasuredFrameTpx3 pxcMeasureMultipleFrames pxcMeasureMultipleFramesWithCa...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Beam_hardening_correction:_Bath_example&amp;diff=475&amp;oldid=prev"/>
		<updated>2023-07-17T11:09:31Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;   = Code = &amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt; &lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;*  * Copyright (C) 2021 ADVACAM  * @author     Pavel Hudecek &amp;lt;pavel.hudecek@advacam.com&amp;gt;  *   * Example of thickness measuring with beam hardening compensation feature  *  B - Bath version: &lt;/span&gt;  /* Used API functions:  pxcGetLastError pxcInitialize pxcGetDevicesCount pxcGetDeviceName pxcGetDeviceChipID  pxcSetTimepix3Mode  pxcMeasureSingleFrameTpx3 pxcGetMeasuredFrameTpx3 pxcMeasureMultipleFrames pxcMeasureMultipleFramesWithCa...&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Code =&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * Copyright (C) 2021 ADVACAM&lt;br /&gt;
 * @author     Pavel Hudecek &amp;lt;pavel.hudecek@advacam.com&amp;gt;&lt;br /&gt;
 * &lt;br /&gt;
 * Example of thickness measuring with beam hardening compensation feature&lt;br /&gt;
 *  B - Bath version&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
/* Used API functions:&lt;br /&gt;
&lt;br /&gt;
pxcGetLastError&lt;br /&gt;
pxcInitialize&lt;br /&gt;
pxcGetDevicesCount&lt;br /&gt;
pxcGetDeviceName&lt;br /&gt;
pxcGetDeviceChipID&lt;br /&gt;
&lt;br /&gt;
pxcSetTimepix3Mode&lt;br /&gt;
&lt;br /&gt;
pxcMeasureSingleFrameTpx3&lt;br /&gt;
pxcGetMeasuredFrameTpx3&lt;br /&gt;
pxcMeasureMultipleFrames&lt;br /&gt;
pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
&lt;br /&gt;
pxcRegisterAcqEvent&lt;br /&gt;
pxcMeasureContinuousTest&lt;br /&gt;
pxcAbortMeasurement&lt;br /&gt;
&lt;br /&gt;
pxcAddBHMask&lt;br /&gt;
pxcBHMaskCount&lt;br /&gt;
pxcRemoveBHMask&lt;br /&gt;
pxcApplyBHCorrection&lt;br /&gt;
pxcGetDeviceBadPixelMatrix&lt;br /&gt;
pxcGetBHBadPixelMatrix&lt;br /&gt;
pxcInterpolateBadPixels&lt;br /&gt;
pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
&lt;br /&gt;
requires: pxcapi.h, pxcore.dll, minipix.dll, pixet.ini, link with pxcore.lib&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
#include &amp;lt;cstring&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;conio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;thread&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;fstream&amp;gt;&lt;br /&gt;
#include &amp;lt;sstream&amp;gt;&lt;br /&gt;
//#include &amp;lt;vector&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
// wait for user choice from 2 to 3 keys (key3=0 or key4=0 -&amp;gt; not used)&lt;br /&gt;
// key1/key2/key3 is lower case, keyboard input is independent ===================================&lt;br /&gt;
char choiceKey(char key1, char * text1, char key2, char * text2, char key3=0, char * text3=&amp;quot;&amp;quot;, char key4=0, char * text4=&amp;quot;&amp;quot;) {&lt;br /&gt;
    char ch;&lt;br /&gt;
&lt;br /&gt;
    while(1) {&lt;br /&gt;
        ch = _getch();&lt;br /&gt;
        if (ch&amp;lt;&amp;#039;a&amp;#039; &amp;amp;&amp;amp; ch&amp;gt;=&amp;#039;A&amp;#039; &amp;amp;&amp;amp; ch&amp;lt;=&amp;#039;Z&amp;#039;) ch += &amp;#039;z&amp;#039;-&amp;#039;Z&amp;#039;; // convert to lower case&lt;br /&gt;
        if (ch==key1) {&lt;br /&gt;
            if (text1[0]!=0) printf(&amp;quot;%s\n&amp;quot;, text1);&lt;br /&gt;
            break;&lt;br /&gt;
        } else if (ch==key2) {&lt;br /&gt;
            if (text2[0]!=0) printf(&amp;quot;%s\n&amp;quot;, text2);&lt;br /&gt;
            break;&lt;br /&gt;
        } else if (key3!=0) if (ch==key3) {&lt;br /&gt;
            if (text3[0]!=0) printf(&amp;quot;%s\n&amp;quot;, text3);&lt;br /&gt;
            break;&lt;br /&gt;
        } else if (key4!=0) if (ch==key4) {&lt;br /&gt;
            if (text4[0]!=0) printf(&amp;quot;%s\n&amp;quot;, text4);&lt;br /&gt;
            break;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    return ch;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#define ERRMSG_BUFF_SIZE    512&lt;br /&gt;
#define ENTER_ON            true&lt;br /&gt;
#define ENTER_OFF           false&lt;br /&gt;
&lt;br /&gt;
// primary use to show function name, return code, last error message and optional enter&lt;br /&gt;
void printErrors(const char* fName, int rc, bool enter) { // ===================================&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#define ABORT_only  true&lt;br /&gt;
#define ABORT_ask   false&lt;br /&gt;
&lt;br /&gt;
// if rc!=0 printError and return true or ask the user for quit (return true for quit)&lt;br /&gt;
bool errorCheck(char * fName, int rc, bool abortOnly) { // =====================================&lt;br /&gt;
    if (rc!=0) {&lt;br /&gt;
        printErrors(fName, rc, ENTER_ON);&lt;br /&gt;
        printf(&amp;quot;Press A to abort or C to continue:\n&amp;quot;);&lt;br /&gt;
        if (abortOnly==ABORT_ask) {&lt;br /&gt;
            if (choiceKey(&amp;#039;a&amp;#039;, &amp;quot;Choice: Abort&amp;quot;, &amp;#039;c&amp;#039;, &amp;quot;Choice: Continue&amp;quot;)==&amp;#039;c&amp;#039;) return false;&lt;br /&gt;
        }&lt;br /&gt;
        return true;&lt;br /&gt;
    }&lt;br /&gt;
    return false;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#define CHT_Si      0&lt;br /&gt;
#define CHT_CdTe    1&lt;br /&gt;
char chipType = CHT_Si;&lt;br /&gt;
&lt;br /&gt;
const unsigned CHIP_xRes = 256;&lt;br /&gt;
const unsigned CHIP_yRes = 256;&lt;br /&gt;
const unsigned CHIP_pixels = CHIP_xRes * CHIP_yRes;&lt;br /&gt;
&lt;br /&gt;
unsigned fileIdx=0;           // index of saved file&lt;br /&gt;
double saveTmpD[CHIP_pixels]; // temp for convert in saveTo.. overload&lt;br /&gt;
&lt;br /&gt;
// Save image to file. Fname add info: exposition, min, max, limit (frames*1023), chip&lt;br /&gt;
// Data auto-ranged to min-max&lt;br /&gt;
// Filename is automatically incremented, but only in the session. Old files can be overwritten.&lt;br /&gt;
void saveToBMP(double *frame, char *info, double expos, unsigned limit=0) { // ============================&lt;br /&gt;
    const unsigned HEAD_end = 54;&lt;br /&gt;
    static unsigned char fTmp[HEAD_end + CHIP_pixels * 3] = { // image file temp&lt;br /&gt;
        &amp;#039;B&amp;#039;, &amp;#039;M&amp;#039;, 54, 0, 3, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0,&lt;br /&gt;
        0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 24, 0, 0, 0,&lt;br /&gt;
        0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,    0, 0, 0, 0, 0, 0&lt;br /&gt;
    };  // header of 24b BMP file, size 256x256&lt;br /&gt;
    // 2-6 file size, 10-14 data offset, 14-17 DIB head size, 18-21 width, 22-25 height, 28/29 bits per px, 38-41 x pix/m, 42-45 y pix/m&lt;br /&gt;
    char fName[150];&lt;br /&gt;
    char chip[]=&amp;quot;CdTe&amp;quot;;&lt;br /&gt;
    FILE *imageFile;&lt;br /&gt;
    unsigned n;&lt;br /&gt;
&lt;br /&gt;
    printf(&amp;quot;Saving... &amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    double min=4000000000.0, max=0.0;&lt;br /&gt;
    for (n=0; n&amp;lt;CHIP_pixels; n++) {&lt;br /&gt;
        if (frame[n]&amp;lt;min) min = frame[n];&lt;br /&gt;
        if (frame[n]&amp;gt;max) max = frame[n];&lt;br /&gt;
    }&lt;br /&gt;
    for (n=0; n&amp;lt;CHIP_pixels; n++) { // convert the data -----------------&lt;br /&gt;
        fTmp[HEAD_end+n*3+0] = (unsigned char)((frame[n]-min) * 255.0 / (max-min));&lt;br /&gt;
        fTmp[HEAD_end+n*3+1] = (unsigned char)((frame[n]-min) * 255.0 / (max-min));&lt;br /&gt;
        fTmp[HEAD_end+n*3+2] = (unsigned char)((frame[n]-min) * 255.0 / (max-min));&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    if (++fileIdx&amp;gt;999) fileIdx=0;&lt;br /&gt;
    if (chipType==CHT_Si) strcpy_s(chip, 5, &amp;quot;Si&amp;quot;);&lt;br /&gt;
    sprintf_s(fName, 150, &amp;quot;img-%03u-%s exp_%1.2e_s min_%1.2e max_%1.2e lim_%u %s.bmp&amp;quot;, fileIdx, info, expos, min, max, limit, chip);&lt;br /&gt;
&lt;br /&gt;
    if (fopen_s(&amp;amp;imageFile, fName, &amp;quot;wb&amp;quot;)!=0) {&lt;br /&gt;
        printf(&amp;quot;ERROR: Cannot open image file&amp;quot;);&lt;br /&gt;
        return;&lt;br /&gt;
    }&lt;br /&gt;
    for (n = 0; n &amp;lt; HEAD_end + CHIP_pixels*3; n++) {&lt;br /&gt;
        fprintf(imageFile, &amp;quot;%c&amp;quot;, fTmp[n]);&lt;br /&gt;
    }&lt;br /&gt;
    fclose(imageFile);&lt;br /&gt;
    printf(&amp;quot;Saved file: %s\n&amp;quot;, fName);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void saveToBMP(unsigned *frame, char *info, double expos, unsigned limit=0) { // ==========================&lt;br /&gt;
    for (unsigned n=0; n&amp;lt;CHIP_pixels; n++) {&lt;br /&gt;
        saveTmpD[n] = (double)frame[n];&lt;br /&gt;
    }&lt;br /&gt;
    saveToBMP(saveTmpD, info, expos, limit);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void saveToTXT(double *frame, char *info, double expos, unsigned limit=0) { // ============================&lt;br /&gt;
    char fName[150];&lt;br /&gt;
    char chip[]=&amp;quot;CdTe&amp;quot;;&lt;br /&gt;
    FILE *imageFile;&lt;br /&gt;
    unsigned n;&lt;br /&gt;
&lt;br /&gt;
    printf(&amp;quot;Saving... &amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    double min=4000000000.0, max=0.0;&lt;br /&gt;
    for (n=0; n&amp;lt;CHIP_pixels; n++) {&lt;br /&gt;
        if (frame[n]&amp;lt;min) min = frame[n];&lt;br /&gt;
        if (frame[n]&amp;gt;max) max = frame[n];&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
   if (++fileIdx&amp;gt;999) fileIdx=0;&lt;br /&gt;
    if (chipType==CHT_Si) strcpy_s(chip, 5, &amp;quot;Si&amp;quot;);&lt;br /&gt;
    sprintf_s(fName, 150, &amp;quot;img-%03u-%s exp_%1.2e_s min_%1.2e max_%1.2e lim_%u %s.txt&amp;quot;, fileIdx, info, expos, min, max, limit, chip);&lt;br /&gt;
&lt;br /&gt;
    if (fopen_s(&amp;amp;imageFile, fName, &amp;quot;wt&amp;quot;)!=0) {&lt;br /&gt;
        printf(&amp;quot;ERROR: Cannot open image file&amp;quot;);&lt;br /&gt;
        return;&lt;br /&gt;
    }&lt;br /&gt;
    for (n = 0; n &amp;lt; CHIP_pixels; n++) {&lt;br /&gt;
        fprintf(imageFile, &amp;quot;%f&amp;quot;, frame[n]);&lt;br /&gt;
        if (n &amp;lt; CHIP_pixels-1 &amp;amp;&amp;amp; !(n % 256)) fprintf(imageFile, &amp;quot;\n&amp;quot;);&lt;br /&gt;
        else fprintf(imageFile, &amp;quot;, &amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    fclose(imageFile);&lt;br /&gt;
    printf(&amp;quot;Saved file: %s\n&amp;quot;, fName);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void saveToTXT(unsigned *frame, char *info, double expos, unsigned limit=0) { // ============================&lt;br /&gt;
    for (unsigned n=0; n&amp;lt;CHIP_pixels; n++) {&lt;br /&gt;
        saveTmpD[n] = (double)frame[n];&lt;br /&gt;
    }&lt;br /&gt;
    saveToTXT(saveTmpD, info, expos, limit);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// show 1 line histogram of single frame&lt;br /&gt;
void showHistogram(unsigned *data) { // ==========================================================&lt;br /&gt;
    unsigned hist[100+5];&lt;br /&gt;
    unsigned n, max, hDiv, avg;&lt;br /&gt;
&lt;br /&gt;
    for (n=0; n&amp;lt;100; n++) hist[n]=0;&lt;br /&gt;
&lt;br /&gt;
    for (n=0, max=0; n&amp;lt;CHIP_pixels; n++) if (data[n]&amp;gt;max) max=data[n];&lt;br /&gt;
    hDiv = max/100;&lt;br /&gt;
&lt;br /&gt;
    for (n=0; n&amp;lt;CHIP_pixels; n++) hist[data[n]/hDiv]++;&lt;br /&gt;
&lt;br /&gt;
    for (n=0, max=0, avg=0; n&amp;lt;100; n++) {&lt;br /&gt;
        if (hist[n]&amp;gt;max) max=hist[n];&lt;br /&gt;
        avg += hist[n];&lt;br /&gt;
    }&lt;br /&gt;
    avg /= 100;&lt;br /&gt;
&lt;br /&gt;
    printf(&amp;quot;Histogram: 0|&amp;quot;);&lt;br /&gt;
    for (n=0; n&amp;lt;100; n++) {&lt;br /&gt;
        if (hist[n]&amp;gt;=avg*10) {&lt;br /&gt;
            printf(&amp;quot;#&amp;quot;);&lt;br /&gt;
        } else if (hist[n]&amp;gt;=avg*2) {&lt;br /&gt;
            printf(&amp;quot;*&amp;quot;);&lt;br /&gt;
        } else if (hist[n]&amp;gt;=avg/5) {&lt;br /&gt;
            putchar(&amp;#039;0&amp;#039; + (hist[n] * 5) / avg);&lt;br /&gt;
        } else if (hist[n]&amp;gt;=avg/10) {&lt;br /&gt;
            printf(&amp;quot;.&amp;quot;);&lt;br /&gt;
        } else {&lt;br /&gt;
            printf(&amp;quot;_&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    printf(&amp;quot;|max\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// integrate multiple acqs to &amp;quot;data&amp;quot; array&lt;br /&gt;
int multiAcq(double frameTime, unsigned frameCount, unsigned *data) { // ================================&lt;br /&gt;
    static unsigned short frameTotEvent[CHIP_pixels];&lt;br /&gt;
    static double tmp[CHIP_pixels];&lt;br /&gt;
    int rc;          // return codes&lt;br /&gt;
    unsigned fn, pn; // frame number, pixel number&lt;br /&gt;
    unsigned size = CHIP_pixels;   // buffer/chip pixel count, input/output pxcMeasureSingleFrameTpx3&lt;br /&gt;
&lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;multiAcq time=&amp;quot; &amp;lt;&amp;lt; frameTime &amp;lt;&amp;lt; &amp;quot; cnt=&amp;quot; &amp;lt;&amp;lt; frameCount &amp;lt;&amp;lt; &amp;quot;: &amp;quot;;&lt;br /&gt;
    for (pn=0; pn&amp;lt;CHIP_pixels; pn++) data[pn]=0;&lt;br /&gt;
&lt;br /&gt;
    for (fn=0; fn&amp;lt;frameCount; fn++) {&lt;br /&gt;
        cout &amp;lt;&amp;lt; &amp;quot;.&amp;quot;;&lt;br /&gt;
        rc = pxcMeasureSingleFrameTpx3(0, frameTime, tmp, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
        if (rc!=0) return rc;&lt;br /&gt;
        for (pn=0; pn&amp;lt;CHIP_pixels; pn++) data[pn] += (unsigned)frameTotEvent[pn];&lt;br /&gt;
    }&lt;br /&gt;
    cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
    showHistogram(data);&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
inline string trim(string&amp;amp; str) { // =====================================================================&lt;br /&gt;
    str.erase(0, str.find_first_not_of(&amp;#039; &amp;#039;));       //prefixing spaces&lt;br /&gt;
    str.erase(str.find_last_not_of(&amp;#039; &amp;#039;)+1);         //surfixing spaces&lt;br /&gt;
    return str;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int measureThicknessBH() { // ============================================================================&lt;br /&gt;
    int rc;                         // return codes&lt;br /&gt;
    unsigned frameTmp[CHIP_pixels]; // measured data&lt;br /&gt;
    double frameOut[CHIP_pixels];   // BH corrected output data&lt;br /&gt;
    unsigned char badPixels[CHIP_pixels];// combined &amp;quot;bad&amp;quot; pixels from pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
    double frameTime;               // frame acquisition time&lt;br /&gt;
    double refThick;                // thickness of ref. plate&lt;br /&gt;
    char fileSet;                   // files setting: d - data, p - picture, b - both, n - none&lt;br /&gt;
    char bpSet;                     // bad px setting: c - chip, b - BH system&lt;br /&gt;
    string name;                    // line name/comment and used in output filenames&lt;br /&gt;
    unsigned size = CHIP_pixels; // buffer/chip pixel count, input/output pxcMeasureSingleFrameTpx3&lt;br /&gt;
    string line, valStr;            // for config lines decoding&lt;br /&gt;
    fstream cfgFile(&amp;quot;config.txt&amp;quot;, ios::in);&lt;br /&gt;
    unsigned n, lineCnt;&lt;br /&gt;
    char fileOutName[20], fileOutName2[20], fileOutName3[20]; // output filenames&lt;br /&gt;
&lt;br /&gt;
    rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_EVENT_ITOT); // set mode on device 0&lt;br /&gt;
    if (errorCheck(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ABORT_ask)) return -1;&lt;br /&gt;
    lineCnt=1;&lt;br /&gt;
	while (getline(cfgFile, line, &amp;#039;\n&amp;#039;)) {&lt;br /&gt;
		cout &amp;lt;&amp;lt; &amp;quot;L &amp;quot; &amp;lt;&amp;lt; lineCnt++ &amp;lt;&amp;lt; &amp;quot; &amp;gt; &amp;quot; &amp;lt;&amp;lt; line &amp;lt;&amp;lt; endl;&lt;br /&gt;
        stringstream linestream(line);&lt;br /&gt;
        getline(linestream, valStr, &amp;#039;,&amp;#039;);&lt;br /&gt;
        switch (valStr.at(0)) { // -------------------------------------------------------&lt;br /&gt;
            case &amp;#039;o&amp;#039;: // comment&lt;br /&gt;
                break;&lt;br /&gt;
            case &amp;#039;r&amp;#039;: // reference&lt;br /&gt;
            case &amp;#039;m&amp;#039;: // measuring&lt;br /&gt;
                cout &amp;lt;&amp;lt; &amp;quot;- Prepare this step and pres Y to do this, or press N to No: &amp;quot;;&lt;br /&gt;
                if (choiceKey(&amp;#039;y&amp;#039;, &amp;quot;Yes&amp;quot;, &amp;#039;n&amp;#039;, &amp;quot;No&amp;quot;)==&amp;#039;n&amp;#039;) continue;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        switch (valStr.at(0)) { // -------------------------------------------------------&lt;br /&gt;
            case &amp;#039;o&amp;#039;: // comment&lt;br /&gt;
                break;&lt;br /&gt;
            case &amp;#039;r&amp;#039;: // reference -----------------------------------------------&lt;br /&gt;
                getline(linestream, valStr, &amp;#039;,&amp;#039;); // ref thick&lt;br /&gt;
                refThick = stof(valStr);&lt;br /&gt;
                getline(linestream, valStr, &amp;#039;,&amp;#039;); // acq time&lt;br /&gt;
                frameTime = stof(valStr);&lt;br /&gt;
                getline(linestream, valStr, &amp;#039;,&amp;#039;); // num of expositions&lt;br /&gt;
                n = stoi(valStr);&lt;br /&gt;
                multiAcq(frameTime, n, frameTmp); // measure&lt;br /&gt;
                getline(linestream, valStr, &amp;#039;,&amp;#039;); // file saving settings&lt;br /&gt;
                fileSet = trim(valStr).at(0);&lt;br /&gt;
                //cout &amp;lt;&amp;lt; &amp;quot;fs &amp;gt;&amp;quot; &amp;lt;&amp;lt; valStr &amp;lt;&amp;lt; &amp;quot;&amp;lt;&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
                getline(linestream, name, &amp;#039;,&amp;#039;);   // name of the step and files&lt;br /&gt;
                name = trim(name);&lt;br /&gt;
                if (fileSet!=&amp;#039;n&amp;#039;) {&lt;br /&gt;
                    cout &amp;lt;&amp;lt; &amp;quot;save &amp;quot; &amp;lt;&amp;lt; name &amp;lt;&amp;lt; &amp;quot; set=&amp;quot; &amp;lt;&amp;lt; fileSet &amp;lt;&amp;lt; endl;&lt;br /&gt;
                    strcpy_s(fileOutName, 20, name.c_str());&lt;br /&gt;
                }&lt;br /&gt;
                if (fileSet==&amp;#039;d&amp;#039;) {         // data file&lt;br /&gt;
                    saveToTXT(frameTmp, fileOutName, frameTime*(double)n, 1023*n);&lt;br /&gt;
                } else if (fileSet==&amp;#039;p&amp;#039;) {  // picture file&lt;br /&gt;
                    saveToBMP(frameTmp, fileOutName, frameTime*(double)n, 1023*n);&lt;br /&gt;
                } else if (fileSet==&amp;#039;b&amp;#039;) {  // both files&lt;br /&gt;
                    saveToBMP(frameTmp, fileOutName, frameTime*(double)n, 1023*n);&lt;br /&gt;
                    saveToTXT(frameTmp, fileOutName, frameTime*(double)n, 1023*n);&lt;br /&gt;
                }&lt;br /&gt;
                rc = pxcAddBHMask(frameTmp, CHIP_pixels, frameTime*(double)n, refThick);&lt;br /&gt;
                if (errorCheck(&amp;quot;pxcAddBHMask&amp;quot;, rc, ABORT_ask)) return -1;&lt;br /&gt;
                break;&lt;br /&gt;
            case &amp;#039;m&amp;#039;: // measuring ---------------------------------------------------&lt;br /&gt;
                getline(linestream, valStr, &amp;#039;,&amp;#039;); // acq time&lt;br /&gt;
                frameTime = stof(valStr);&lt;br /&gt;
                getline(linestream, valStr, &amp;#039;,&amp;#039;); // num of expositions&lt;br /&gt;
                n = stoi(valStr);&lt;br /&gt;
                multiAcq(frameTime, n, frameTmp); // measure&lt;br /&gt;
                getline(linestream, valStr, &amp;#039;,&amp;#039;); // bad px settings&lt;br /&gt;
                bpSet = trim(valStr).at(0);&lt;br /&gt;
                getline(linestream, valStr, &amp;#039;,&amp;#039;); // file saving settings&lt;br /&gt;
                fileSet = trim(valStr).at(0);&lt;br /&gt;
                getline(linestream, name, &amp;#039;,&amp;#039;);   // name of the step and files&lt;br /&gt;
                name = trim(name);&lt;br /&gt;
                if (fileSet!=&amp;#039;n&amp;#039;) {&lt;br /&gt;
                    cout &amp;lt;&amp;lt; &amp;quot;save &amp;quot; &amp;lt;&amp;lt; name &amp;lt;&amp;lt; &amp;quot; set=&amp;quot; &amp;lt;&amp;lt; fileSet &amp;lt;&amp;lt; endl;&lt;br /&gt;
                    strcpy_s(fileOutName,  20, (name + &amp;quot;-raw&amp;quot;).c_str());&lt;br /&gt;
                    strcpy_s(fileOutName2, 20, (name + &amp;quot;-bhc&amp;quot;).c_str());&lt;br /&gt;
                    strcpy_s(fileOutName3, 20, (name + &amp;quot;-bpc&amp;quot;).c_str());&lt;br /&gt;
                }&lt;br /&gt;
                if (fileSet==&amp;#039;d&amp;#039;) {         // data file raw&lt;br /&gt;
                    saveToTXT(frameTmp, fileOutName, frameTime*(double)n, 1023*n);&lt;br /&gt;
                } else if (fileSet==&amp;#039;p&amp;#039;) {  // picture file raw&lt;br /&gt;
                    saveToBMP(frameTmp, fileOutName, frameTime*(double)n, 1023*n);&lt;br /&gt;
                } else if (fileSet==&amp;#039;b&amp;#039;) {  // both files raw&lt;br /&gt;
                    saveToBMP(frameTmp, fileOutName, frameTime*(double)n, 1023*n);&lt;br /&gt;
                    saveToTXT(frameTmp, fileOutName, frameTime*(double)n, 1023*n);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
                rc = pxcApplyBHCorrection(frameTmp, CHIP_pixels, frameTime*(double)n, frameOut);&lt;br /&gt;
                if (errorCheck(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc, ABORT_ask)) return -1;&lt;br /&gt;
&lt;br /&gt;
                if (fileSet==&amp;#039;d&amp;#039;) {         // data file BH corrected&lt;br /&gt;
                    saveToTXT(frameOut, fileOutName2, frameTime*(double)n, 1023*n);&lt;br /&gt;
                } else if (fileSet==&amp;#039;p&amp;#039;) {  // picture file BH corrected&lt;br /&gt;
                    saveToBMP(frameOut, fileOutName2, frameTime*(double)n, 1023*n);&lt;br /&gt;
                } else if (fileSet==&amp;#039;b&amp;#039;) {  // both files BH corrected&lt;br /&gt;
                    saveToBMP(frameOut, fileOutName2, frameTime*(double)n, 1023*n);&lt;br /&gt;
                    saveToTXT(frameOut, fileOutName2, frameTime*(double)n, 1023*n);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
                if (bpSet==&amp;#039;d&amp;#039;) { // bad px setting: d - device, b - device + BH system&lt;br /&gt;
                    rc = pxcGetDeviceBadPixelMatrix(0, badPixels, CHIP_pixels);&lt;br /&gt;
                    if (errorCheck(&amp;quot;pxcGetDeviceBadPixelMatrix&amp;quot;, rc, ABORT_ask)) return -1;&lt;br /&gt;
                } else {&lt;br /&gt;
                    rc = pxcGetDeviceAndBHBadPixelMatrix(0, badPixels, CHIP_pixels);&lt;br /&gt;
                    if (errorCheck(&amp;quot;pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc, ABORT_ask)) return -1;&lt;br /&gt;
                }&lt;br /&gt;
                //for (n=0; n&amp;lt;CHIP_pixels; n++) badPixels[n] = (unsigned char)frameTmp[n];&lt;br /&gt;
                rc = pxcInterpolateBadPixels(badPixels, frameOut, 256, 256);&lt;br /&gt;
                if (errorCheck(&amp;quot;pxcInterpolateBadPixels&amp;quot;, rc, ABORT_ask)) return -1;&lt;br /&gt;
&lt;br /&gt;
                if (fileSet==&amp;#039;d&amp;#039;) {         // data file BH+BP corrected&lt;br /&gt;
                    saveToTXT(frameOut, fileOutName3, frameTime*(double)n, 1023*n);&lt;br /&gt;
                } else if (fileSet==&amp;#039;p&amp;#039;) {  // picture file BH+BP corrected&lt;br /&gt;
                    saveToBMP(frameOut, fileOutName3, frameTime*(double)n, 1023*n);&lt;br /&gt;
                } else if (fileSet==&amp;#039;b&amp;#039;) {  // both files BH+BP corrected&lt;br /&gt;
                    saveToBMP(frameOut, fileOutName3, frameTime*(double)n, 1023*n);&lt;br /&gt;
                    saveToTXT(frameOut, fileOutName3, frameTime*(double)n, 1023*n);&lt;br /&gt;
                }&lt;br /&gt;
                break;&lt;br /&gt;
            &lt;br /&gt;
            default:&lt;br /&gt;
                cout &amp;lt;&amp;lt; &amp;quot;Unknown line type: &amp;quot; &amp;lt;&amp;lt; valStr &amp;lt;&amp;lt; endl;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main (int argc, char const* argv[]) { // ###################################################&lt;br /&gt;
    // Initialize Pixet&lt;br /&gt;
    int rc = pxcInitialize();&lt;br /&gt;
    if (rc) {&lt;br /&gt;
        printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
        printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
        return -1;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
    printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
&lt;br /&gt;
    if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
&lt;br /&gt;
    for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++){&lt;br /&gt;
        char deviceName[256];&lt;br /&gt;
        memset(deviceName, 0, 256);&lt;br /&gt;
        pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
&lt;br /&gt;
        char chipID[256];&lt;br /&gt;
        memset(chipID, 0, 256);&lt;br /&gt;
        pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
        printf(&amp;quot;Device %d: Name %s, (first ChipID: %s), &amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
&lt;br /&gt;
        double bias;&lt;br /&gt;
        rc = pxcGetBias(devIdx, &amp;amp;bias);   &lt;br /&gt;
        if (bias&amp;lt;0.0) {&lt;br /&gt;
            if (devIdx==0) chipType = CHT_CdTe;&lt;br /&gt;
            printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
        } else if (bias==0.0) {&lt;br /&gt;
            if (devIdx==0) chipType = CHT_CdTe;&lt;br /&gt;
            printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
        } else {&lt;br /&gt;
            if (devIdx==0) chipType = CHT_Si;&lt;br /&gt;
            printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
  printf(&amp;quot;====================================================================================================\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    measureThicknessBH();&lt;br /&gt;
&lt;br /&gt;
    printf(&amp;quot;Exiting...\n&amp;quot;); &lt;br /&gt;
    return pxcExit(); // Exit Pixet core&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
</feed>