• DepthAI-v2
  • depthai_sdk code example not working on oak-d-cm4

hello guys, I would appreciate if you can give me hints on executing code samples from depthai_sdk python API. For example this code example, concerning an object detection from a youtube video, does not work as the GUI supposed to show the result, does not appear, and I am getting an error message on a new window.

I use an OAK-D-CM4 (arm32 raspberry os) with the up-to-date version of Depthai

    Hi brick
    Any terminal output you can provide as well? Also, I'd recommend running depthai_sdk==1.12.1 and make sure you install the requirements.

    Thanks,
    Jaka

      5 days later

      jakaskerl

      dear Jaka, as you can see from this execution of the code sample with the python interpreter, the application blocks without printing errors to terminal.

      Unfortunately no code example from the DepthAI sdk works on the oak-d-cm4 which I am using. As regards the dependencies, the operating system image downloaded from Luxonis site is supposed to already have all dependencies, and DepthAI for python is installed in the version ==1.12.1 in the way you recommended

        Hi brick
        I can confirm this runs fine on 1.12.1. The installation is recommended in the other thread will update your version to 1.13.1 (which I checked as well, and it works).

        Could you perhaps try running this modified code to see if you get an output:

        from depthai_sdk import OakCamera
        
        with OakCamera(replay='https://www.youtube.com/watch?v=Y1jTEyb3wiI') as oak:
            color = oak.create_camera('color')
            nn = oak.create_nn('vehicle-detection-0202', color)
            #oak.visualize([nn.out.passthrough], fps=True)
            oak.visualize(nn, scale=2 / 3, fps=True, callback=lambda frame: print(frame.detections))
            oak.start(blocking=True)

        This should be printing out all detections on a frame, without actually showing the frame. Perhaps there is a problem with opencv on your cm4.

        Thanks,
        Jaka

          jakaskerl

          You are right, your code without visualization works and prints the predictions to terminal. I will try to investigate on the GUI issue. You also suspected that the GUI does not start for a problem with opencv, so I tried displaying an image with cv2.imshow() and it works

            Hi brick
            Good to hear.

            brick so I tried displaying an image with cv2.imshow() and it works

            You tried displaying a still frame just to test the opencv right - you didn't use the sdk to display it?

            I'm going to check with a CM4 at the office tomorrow, perhaps there is a problem with the visualizer on the CM4.

            Thanks,
            Jaka

              jakaskerl

              exactly, I imported cv2 library, called cv2.imread() on a file and finally cv2.imshow() and it works with the GUI appearing