# Calibration with StreamImage

**URL:** <https://forum.commonvisionblox.com/t/calibration-with-streamimage/970>\
**Category:** .Net API\
**Created:** [November 27, 2019, 2:36pm UTC](https://forum.commonvisionblox.com/t/calibration-with-streamimage/970 "2019-11-27T14:36:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@Michael](https://forum.commonvisionblox.com/u/Michael)\
**Post date:** [November 27, 2019, 2:36pm UTC](https://forum.commonvisionblox.com/t/calibration-with-streamimage/970/1 "2019-11-27T14:36:13Z")

</div>

I try to read out the data of my camera using the StreamImage Code sample, as well as the calibration code sample. But I never get any data, which is correctly calibrated. Here is the code I use:

```auto
var stream = camera.Stream;

NodeMap nm = camera.NodeMaps[NodeMapNames.Device];
NodeMap cameraNodeMap = camera.NodeMaps[NodeMapNames.Device];

// get calibration file from camera
var files = cameraNodeMap.GetAvailableFiles();
if (files.Contains("UserData"))
    cameraNodeMap.DownloadFile($@"D:\VermessungErgebnisse\CalibrationFile.dat", "UserData");
            
stream.Start();
try
{
    Console.WriteLine("Start streaming");
    while (true)
    {
        using (StreamImage image = stream.Wait())
        {                                           
            var cloud = Calibrator3D.FromFile($@"D:\VermessungErgebnisse\CalibrationFile.dat")
                          .CreatePointCloud<Point3Dd>(image);
            var fileName = DateTime.Now.ToFileTime();                     
            cloud.Save($@"D:\VermessungErgebnisse\Camera\{fileName}.xyz");            
        }
    }
}
finally
{
    stream.Stop();
}

```

After calibration, the data from the camera is still in 2D, but bent like an “U”. If I use the calibration method FromFactors(1,1,1), I get a relative correct data.

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Moli](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/moli/32/553_2.png) [@Moli](https://forum.commonvisionblox.com/u/Moli)\
**Post date:** [November 28, 2019, 8:03am UTC](https://forum.commonvisionblox.com/t/calibration-with-streamimage/970/2 "2019-11-28T08:03:42Z")

</div>

Hi Michael,

taking a look at your code I don’t see why this shouldn’t work.

If a calibration seems to be not valid it can have multiple possible reasons:

- how did you set the output images of the camera. Did you enable only DC2? If not, you need to decode the interleaved information first.
- do the calibration parameters from the calibration file match the acquisition parameters in the camera? In specific the following parameters should be checked:  
_-_ subpixels (rangeScale)  
_-_ encoder resolution (Sy)  
_–\>_ since the .dat file is not readable, please store it in the .xml format (using the CXExplorer of the manufacturer). This way you can check or adapt the parameters. A more automated way to read the parameters is to store the calibration file after downloading it from the camera in CVB’s calibrator format (.json).
- did you set the AbsOffsetPos parameter in the camera to true?
- slight inaccuracies can be a result of using the sensor in a cold state. It is recommended to heat up the sensor for at least 1h before doing precise measurements

---

<div class="post-metadata">

**Author:** ![Michael](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@Michael](https://forum.commonvisionblox.com/u/Michael)\
**Post date:** [November 29, 2019, 3:01pm UTC](https://forum.commonvisionblox.com/t/calibration-with-streamimage/970/3 "2019-11-29T15:01:25Z")

</div>

Hi Moli,

thanks for the reply.

For my test I only enabled DC2.

In my code I read the parameters directly from the camera. Is there some way, that they are different (e.g. subpixels or encoder resultion)?

SubPixels is 6 in configuration and rangeScale is 0.015625. Encoder Resolution is 1, where can I change this parameter in the configuration of the camera?

AbsOffsetPos is true.

I would love to enclose the XML and config file of the camera, but I seems I can´t yet.

EDIT: Here are the contents of the files.

JSON:

> **Summary**
>
> {  
> “cx3d”: {  
> “-xmlns:xsi”: “[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)”,  
> “-MajorVersion”: “1”,  
> “-MinorVersion”: “0”,  
> “-xsi:noNamespaceSchemaLocation”: “cx3d.xsd”,  
> “CalibCase3d”: {  
> “-id”: “cal0”,  
> “name”: “C5-1600CS19-500SN21311685”,  
> “dateTime”: “2019-06-21-12-49-58”,  
> “creator”: “AT-Automation Technology GmbH”,  
> “description”: “Factory Calibration”,  
> “target”: “2”,  
> “sensorSize”: “1600 1088”,  
> “fov”: “0 0 0 0 0 0”,  
> “roc”: “0 0 0 0”,  
> “intrinsic”: {  
> “model”: “65537”,  
> “rangeScale”: “0.015625”,  
> “sensorRoi”: “0 0 1600 63”,  
> “sensorR”: “0 0 0”,  
> “pixelSize”: “0 0”,  
> “f”: “0”,  
> “cp”: “0 0”,  
> “L”: {  
> “rows”: “1”,  
> “cols”: “0”,  
> “dt”: “d”  
> },  
> “P”: {  
> “rows”: “3”,  
> “cols”: “3”,  
> “dt”: “d”,  
> “data”: “1.015830039978027 0.001321549993008375 -798.7839965820313 0.001118979998864233 3.102370023727417 -1689.949951171875 -3.28493001688912e-06 0.0040095797739923 1”  
> },  
> “C”: {  
> “rows”: “15”,  
> “cols”: “2”,  
> “dt”: “d”,  
> “data”: “0.08127669990062714 0.0766431987285614 0.9864400029182434 0.0003397869877517223 -0.0001088709977921098 0.9906460046768188 1.117379997594981e-05 -3.249710061936639e-06 -5.300819793774281e-06 -1.672799953666981e-05 -1.655169967307302e-06 1.213910036312882e-05 -1.678910011015944e-09 3.978639995239064e-07 5.936509950288382e-08 1.882870082070554e-09 3.556399974513624e-07 -3.453709984668762e-09 -2.127370057891653e-09 4.710160084187009e-08 4.132680031521119e-10 -1.571999995453321e-11 -7.847960020561373e-13 4.245669926739026e-10 4.458389907258109e-11 -1.880020011196804e-12 -4.103020007084623e-12 1.499100010793342e-10 1.3546700219913e-11 3.782259921925046e-11”  
> }  
> },  
> “extrinsic”: {  
> “Sy”: “1”,  
> “Sxy”: “0”,  
> “Szy”: “0”,  
> “T”: “0 0 0”,  
> “R”: “0 0 0”  
> },  
> “metric”: {  
> “offset”: “0 0 0”,  
> “scale”: “1 1 1”,  
> “invalidDataValue”: “0”  
> },  
> “accuracyStat”: {  
> “rows”: “4”,  
> “cols”: “3”,  
> “dt”: “d”,  
> “data”: “0 0 0 0 0 0 0 0 0 0 0 0”  
> },  
> “lensCorrStat”: {  
> “rows”: “1”,  
> “cols”: “3”,  
> “dt”: “d”,  
> “data”: “0 0 0”  
> }  
> }  
> }  
> }

Config:

> **Summary**
>
> ```
> {05D8C294-F295-4dfb-9D01-096BD04049F4}
> 
> ```
> 
> GenApi persistence file (version 3.1.0)  
> Device = AutomationTechnology::CX\_CMV\_GigE – AT generic GigEVision interface for CX-CMV Series – Device version = 2.5.0 – Product GUID = F9138771-8EF5-4710-9427-63FE3A7C2101 – Product version GUID = F3B5B91B-A333-4460-8BD9-E38EE40C64FD  
> CameraMode CenterOfGravity  
> FIR 1  
> ProfileTriggerMode EncoderResolverInterfaceRS422  
> EnableDC2 1  
> EnableDC1 0  
> Width 1600  
> PixelFormat Mono16  
> ReverseX 0  
> ReverseY 0  
> OffsetX 0  
> ChunkModeActive 0  
> ChunkModeSelector OneChunkPerFrame  
> AcquisitionMode Continuous  
> AcquisitionFrameCount 1  
> MultiSlopeKneePointCount 1  
> MultiSlopeKneePointSelector 1  
> MultiSlopeExposureLimit 99  
> MultiSlopeKneePointSelector 2  
> MultiSlopeExposureLimit 99  
> MultiSlopeKneePointSelector 1  
> MultiSlopeKneePointSelector 1  
> MultiSlopeSaturationThreshold 60.3175  
> MultiSlopeKneePointSelector 2  
> MultiSlopeSaturationThreshold 49.2063  
> MultiSlopeKneePointSelector 1  
> ExposureTime 500  
> NumAois 1  
> AoiSelector 1  
> AoiSelector 1  
> AoiHeight 63  
> AoiSelector 1  
> AoiSelector 1  
> AoiOffsetY 530  
> AoiSelector 1  
> AoiSelector 1  
> AoiThreshold 120  
> AoiSelector 1  
> FIR 1  
> FIRCoef SG9  
> FIRGain 1  
> FIRCorrection 0  
> CameraMode CenterOfGravity  
> ProfilesPerFrame 1000  
> AbsOffsetPos 1  
> NumSubPixel 6  
> TrshFirstFalling 0  
> TrshFirstZeroCrossing 0  
> MinThrshValidation 1  
> PosValidationEn 0  
> ClearInvalidPos 0  
> ValidationWidthMin 0  
> ValidationWidthMax 1087  
> ValidationSumMin 0  
> ValidationSumMax 65535  
> AoiTrackingEnable 0  
> AoiSearchEnable 0  
> AoiSearchMinNumPixel 100  
> AoiSearchHeight 1088  
> AoiSearchOffsetY 0  
> AoiSearchAlgorithm Mean  
> FramePeriod 737  
> LineStartSyncTrigger 1  
> GainPGA Gain2  
> GainADC 40  
> BlackLevelOffset 16323  
> Vramp1 109  
> Vramp2 109  
> BlackSunControl 98  
> FOT 10  
> DummyRows 1  
> VresLow 64  
> EnableDC2 1  
> EnableDC1 0  
> EnableDC0 0  
> EnableDC1TrshWidth 0  
> EnableDC1Width 0  
> EnableDC1Option 0  
> EnableDC1Flags 0  
> EnableDC2TrshSP 0  
> LightControllerSource ExposureActive  
> LightBrightnessControlMode Analog  
> LightBrightness 50  
> Output1 Out1\_SequencerActive  
> Output2 Out2\_IntegrationActive  
> Output1MinPulseWidth 0  
> Output2MinPulseWidth 0  
> Output1Delay 0  
> Output2Delay 0  
> Output1Invert 0  
> Output2Invert 0  
> SequencerMode StartCameraInput1  
> ProfileTriggerMode EncoderResolverInterfaceRS422  
> TriggerDivider 1  
> TriggerDirectionMode 1  
> TriggerReverseDirection 1  
> TriggerSingleChannelMode Disabled  
> TriggerDividerLoadAtStart 0  
> ResetTriggerCoordZeroPos Off  
> TriggerCoordinateCountAlways 1  
> UseAlternateResolverInputs 0  
> UseAlternateResolverInputsInverted 0  
> GevHeartbeatTimeout 3000  
> GevStreamChannelSelector 0  
> GevSCPSPacketSize 1500  
> GevStreamChannelSelector 0  
> GevStreamChannelSelector 0  
> GevSCPD 5000  
> GevStreamChannelSelector 0  
> EventSelector AcquisitionStart  
> EventSelector AcquisitionStart  
> EventNotification Off  
> EventSelector AcquisitionEnd  
> EventNotification Off  
> EventSelector AcquisitionTransferStart  
> EventNotification Off  
> EventSelector AcquisitionTransferEnd  
> EventNotification Off  
> EventSelector AoiTrackingStart  
> EventNotification Off  
> EventSelector AoiTrackingEnd  
> EventNotification Off  
> EventSelector AoiSearchFailed  
> EventNotification Off  
> EventSelector AutoStartTrigger  
> EventNotification Off  
> EventSelector AcquisitionStart

---

<div class="post-metadata">

**Author:** ![Moli](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/moli/32/553_2.png) [@Moli](https://forum.commonvisionblox.com/u/Moli)\
**Post date:** [December 2, 2019, 1:38pm UTC](https://forum.commonvisionblox.com/t/calibration-with-streamimage/970/4 "2019-12-02T13:38:06Z")

</div>

In some cases it is possible that users of the AT cameras set the subpixel value within the camera to a different value than the one in the calibration file. This would lead to distorted profiles. However, in your case it is set to 6 subpixels in the camera and calib file. So this seems to be fine.

The encoder resolution can only be set in the calibration file, not in the camera.

Can you please send me the acquired range map + calibration file + settings file per PN? This way I can reproduce the resulting point clouds with static factors and with the calibration.

---

<div class="post-metadata">

**Author:** ![Michael](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@Michael](https://forum.commonvisionblox.com/u/Michael)\
**Post date:** [December 18, 2019, 8:46am UTC](https://forum.commonvisionblox.com/t/calibration-with-streamimage/970/5 "2019-12-18T08:46:51Z")

</div>

The Solution was, that the driver had “Auto Detect” as output format. I changed it to RAW and now everything works fine.
