ifm / ifm3d

Library and Utilities for working with ifm pmd-based 3D ToF Cameras
https://api.ifm3d.com
Apache License 2.0
110 stars 69 forks source link

Image retrieval error - Python library #361

Closed nikhilnagaraj closed 1 year ago

nikhilnagaraj commented 2 years ago

Hi,

I am following the tutorial here and I am having trouble retrieving the image.

I encounter this error: image

I am able to connect to the VPU (data packets are received when using ping). The python library version is 0.93 and the firmware version is 0.14.23 . Both the ports (2D and 3D) have been set to RUN.

Is there something I am missing here?

j-friedl commented 2 years ago

Are you using the exact demo code? Also, could you share ifm3d dump?

nikhilnagaraj commented 2 years ago

Yes, the exact demo code. Here's the dump:

{
    "device": {
        "clock": {
            "currentTime": 1581091029598348768
        },
        "diagnostic": {
            "temperatures": [
                {
                    "entity": "PLL-therm",
                    "value": 36.0
                },
                {
                    "entity": "MCPU-therm",
                    "value": 36.0
                },
                {
                    "entity": "PMIC-Die",
                    "value": 100.0
                },
                {
                    "entity": "Tboard_tegra",
                    "value": 33.0
                },
                {
                    "entity": "GPU-therm",
                    "value": 33.0
                },
                {
                    "entity": "BCPU-therm",
                    "value": 36.0
                },
                {
                    "entity": "thermal-fan-est",
                    "value": 34.79999923706055
                },
                {
                    "entity": "Tdiode_tegra",
                    "value": 32.25
                },
                {
                    "entity": "port2",
                    "value": 0
                }
            ],
            "upTime": 385000000000
        },
        "info": {
            "description": "",
            "device": "0302",
            "deviceTreeBinaryBlob": "tegra186-quill-p3310-1000-c03-00-base.dtb",
            "guiSettings": "",
            "name": "",
            "partNumber": "OVP800",
            "productionState": "AA",
            "serialNumber": "000018384491",
            "vendor": "0001"
        },
        "log": {
            "level": "warn",
            "storage": "volatile"
        },
        "network": {
            "authorized_keys": "",
            "interfaces": {
                "eth0": {
                    "ipAddressConfig": 0,
                    "ipv4": {
                        "address": "192.168.0.69",
                        "dns": "192.168.0.255",
                        "gateway": "192.168.0.201",
                        "mask": 24
                    },
                    "mac": "48:B0:2D:54:F6:DA",
                    "networkSpeed": 100,
                    "useDHCP": false
                },
                "eth1": {
                    "ipAddressConfig": 1,
                    "mac": "00:02:01:43:26:9F",
                    "networkSpeed": 10,
                    "useDHCP": true
                }
            }
        },
        "state": {
            "errorMessage": "",
            "errorNumber": ""
        },
        "swVersion": {
            "euphrates": "1.4.3",
            "firmware": "0.14.23-493",
            "kernel": "4.9.140-l4t-r32.4+g1582a8a5405d",
            "l4t": "r32.4.3",
            "schema": "v0.2.4",
            "tcu": "1.0.2"
        }
    },
    "ports": {
        "port0": {
            "acquisition": {
                "framerate": 10.0,
                "version": {
                    "major": 0,
                    "minor": 0,
                    "patch": 0
                }
            },
            "data": {
                "algoDebugConfig": {
                    "channels": [
                        {
                            "id": "ov9782/ifcustom",
                            "type": "normal"
                        },
                        {
                            "id": "ov9782/profile",
                            "type": "normal"
                        },
                        {
                            "id": "ov9782/dbg",
                            "type": "normal"
                        },
                        {
                            "id": "ov9782/calib",
                            "type": "once"
                        },
                        {
                            "id": "ov9782/ifout",
                            "type": "normal"
                        },
                        {
                            "id": "ov9782/frameInfo",
                            "type": "normal"
                        }
                    ],
                    "version": {
                        "major": 0,
                        "minor": 11,
                        "patch": 12
                    }
                },
                "availablePCICOutput": [
                    "RGB_INFO"
                ],
                "pcicTCPPort": 50010
            },
            "info": {
                "calibration": {
                    "version": {
                        "major": 0,
                        "minor": 1,
                        "patch": 1
                    }
                },
                "device": "2301",
                "deviceTreeBinaryBlobOverlay": "001-ov9782.dtbo",
                "features": {
                    "fov": {
                        "horizontal": 127,
                        "vertical": 80
                    },
                    "resolution": {
                        "height": 800,
                        "width": 1280
                    },
                    "type": "2D"
                },
                "icc": {
                    "version": {
                        "major": 0,
                        "minor": 0,
                        "patch": 0
                    }
                },
                "name": "",
                "partNumber": "O3R225",
                "productionState": "AA",
                "sensor": "OV9782",
                "sensorID": "OV9782_127x80_noIllu_Csample",
                "serialNumber": "000017921762",
                "vendor": "0001",
                "version": {
                    "major": 11,
                    "minor": 1,
                    "patch": 0
                }
            },
            "mode": "experimental_autoexposure2D",
            "processing": {
                "extrinsicHeadToUser": {
                    "rotX": 0.0,
                    "rotY": 0.0,
                    "rotZ": 0.0,
                    "transX": 0.0,
                    "transY": 0.0,
                    "transZ": 0.0
                },
                "version": {
                    "major": 0,
                    "minor": 11,
                    "patch": 12
                }
            },
            "state": "RUN"
        },
        "port2": {
            "acquisition": {
                "channelSelection": "manual",
                "channelValue": 0,
                "exposureLong": 5000,
                "exposureShort": 400,
                "framerate": 10.0,
                "offset": 0.0,
                "version": {
                    "major": 0,
                    "minor": 0,
                    "patch": 0
                }
            },
            "data": {
                "algoDebugConfig": {
                    "channels": [
                        {
                            "id": "irs2381/ifcustom",
                            "type": "normal"
                        },
                        {
                            "id": "irs2381/profile",
                            "type": "normal"
                        },
                        {
                            "id": "irs2381/dbg",
                            "type": "normal"
                        },
                        {
                            "id": "irs2381/calib",
                            "type": "once"
                        },
                        {
                            "id": "irs2381/ifout_compr",
                            "type": "normal"
                        },
                        {
                            "id": "irs2381/raw/mode",
                            "type": "normal"
                        },
                        {
                            "id": "irs2381/raw/0",
                            "type": "normal"
                        },
                        {
                            "id": "irs2381/raw/1",
                            "type": "normal"
                        },
                        {
                            "id": "irs2381/raw/2",
                            "type": "normal"
                        },
                        {
                            "id": "irs2381/raw/3",
                            "type": "normal"
                        },
                        {
                            "id": "irs2381/raw/4",
                            "type": "normal"
                        },
                        {
                            "id": "irs2381/raw/5",
                            "type": "normal"
                        },
                        {
                            "id": "irs2381/raw/6",
                            "type": "normal"
                        },
                        {
                            "id": "irs2381/raw/7",
                            "type": "normal"
                        },
                        {
                            "id": "irs2381/raw/8",
                            "type": "normal"
                        },
                        {
                            "id": "irs2381/raw/9",
                            "type": "normal"
                        },
                        {
                            "id": "irs2381/raw/10",
                            "type": "normal"
                        },
                        {
                            "id": "irs2381/raw/11",
                            "type": "normal"
                        },
                        {
                            "id": "irs2381/raw/12",
                            "type": "normal"
                        },
                        {
                            "id": "irs2381/raw/13",
                            "type": "normal"
                        },
                        {
                            "id": "irs2381/raw/14",
                            "type": "normal"
                        },
                        {
                            "id": "irs2381/raw/15",
                            "type": "normal"
                        }
                    ],
                    "version": {
                        "major": 0,
                        "minor": 11,
                        "patch": 12
                    }
                },
                "availablePCICOutput": [
                    "TOF_INFO",
                    "RADIAL_DISTANCE_NOISE",
                    "RADIAL_DISTANCE_COMPRESSED",
                    "REFLECTIVITY",
                    "AMPLITUDE_COMPRESSED",
                    "CONFIDENCE"
                ],
                "pcicTCPPort": 50012
            },
            "info": {
                "calibration": {
                    "version": {
                        "major": 0,
                        "minor": 5,
                        "patch": 1
                    }
                },
                "device": "3101",
                "deviceTreeBinaryBlobOverlay": "001-irs2381c.dtbo",
                "features": {
                    "fov": {
                        "horizontal": 105,
                        "vertical": 78
                    },
                    "resolution": {
                        "height": 172,
                        "width": 224
                    },
                    "type": "3D"
                },
                "icc": {
                    "version": {
                        "major": 1,
                        "minor": 0,
                        "patch": 4
                    }
                },
                "name": "",
                "partNumber": "O3R225",
                "productionState": "AA",
                "sensor": "IRS2381C",
                "sensorID": "IRS2381C_105x78_4x2W_110x90_C7",
                "serialNumber": "000017921762",
                "vendor": "0001",
                "version": {
                    "major": 11,
                    "minor": 1,
                    "patch": 0
                }
            },
            "mode": "standard_range4m",
            "processing": {
                "diParam": {
                    "anfFilterSizeDiv2": 2,
                    "dynamicSymmetryThreshold": 20.0,
                    "enableTemporalFilter": true,
                    "maxDistNoise": 0.05,
                    "medianSizeDiv2": 0,
                    "minAmplitude": 20.0,
                    "minReflectivity": 2.0,
                    "mixedPixelFilterMode": 1,
                    "mixedPixelThresholdRad": 0.05
                },
                "extrinsicHeadToUser": {
                    "rotX": 0.0,
                    "rotY": 0.0,
                    "rotZ": 0.0,
                    "transX": 0.0,
                    "transY": 0.0,
                    "transZ": 0.0
                },
                "version": {
                    "major": 0,
                    "minor": 11,
                    "patch": 12
                }
            },
            "state": "RUN"
        }
    }
}

EDIT: Just checked my code again. I'm using the same code but still receive the RuntimeError.

inbangsa commented 2 years ago

@nikhilnagaraj Can you please specify the Platform/OS you are using along with how you installed ifm3dpy and if possible please share the sample code that's producing the error.

nikhilnagaraj commented 2 years ago

@inbangsa

@nikhilnagaraj Can you please specify the Platform/OS you are using along with how you installed ifm3dpy and if possible please share the sample code that's producing the error.

I am running it on WSL (Ubuntu). The sample code is

from ifm3dpy import O3RCamera, FrameGrabber, ImageBuffer
import matplotlib.pyplot as plt

o3r = O3RCamera()
config = o3r.get()
config["ports"]["port0"]["state"] = "RUN"
config["ports"]["port2"]["state"] = "RUN"
o3r.set(config)
fg = FrameGrabber(o3r, pcic_port=50010) #Expecting a head on Port 0 (Port 0 == 50010)
im = ImageBuffer()

if fg.wait_for_frame(im, 1000):
    plt.imsave("saved_image.png", im.distance_image())
    # Same error with plt.imshow(...)

Installed the python library with pip install ifm3dpy.

inbangsa commented 2 years ago

@nikhilnagaraj

fg = FrameGrabber(o3r, pcic_port=50010) can you please change the port to 50012.

port0->50010-> 2D image Port2 -> 50012 -> 3D image ( Distance, Amplitude, xyz)

nikhilnagaraj commented 2 years ago

@inbangsa

Perfect! That works :) Should have spotted this myself.

Would recommend changing it in the docs and if possible making the error message more descriptive. If you can point me to the appropriate location, I can create a PR for the same.

lola-masson commented 2 years ago

Hi @nikhilnagaraj, Happy to accept PRs, thanks for offering. The examples are implemented here along with md doc. Please keep in mind that the o3r/main-next branch is a work in progress and currently contains breaking changes to the API. I recommend pointing to the v0.93.0 branch in your PR and we will integrate your changes to the next API release.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 14 days since being marked as stale.