Segmentation Fault from cvSink

Hello,
Currently, our team is trying to use an orangepi5 to run custom vision code. We have an Ubuntu Jammy Server installed on it with cscore, ntcore, openCV headless, and a bunch of other libraries installed on it.

We followed this example (robotpy-cscore/examples/intermediate_cameraserver.py at main · robotpy/robotpy-cscore · GitHub), but we’re getting Segmentation Faults. We got rid of all of the rectangle stuff and confirmed that we’re getting a proper connection to Camera Server because we can see stuff from Shuffleboard, but when we add “time, sink = cvSink.getFrame(img)” into our code, it gives us the Segmentation Fault.

Here is the output and the code we used (I don’t know how to copy things from terminal):



Can someone help us fix this? Thanks!

Can you get a stack trace? gdb --args python3 vision_test3.py… type r to run, and when it crashes then do bt and put that here.

I tried running the command, but I got this error message instead

You need to install gdb via apt then?

I installed it and ran it. Here’s what showed.

Thanks, that’s helpful. It looks like there’s a bug in the robotpy cscore bindings, I was able to reproduce the issue locally. I’ll take a look tonight.

Thank you!

This is going to be challenging to solve, so I’ll have to look at it later.

The core problem is that the original numpy array is being destroyed, and the new numpy array is referring to the old data. To prevent the crash from happening, you just need to keep a reference to the original data:

img = np.zeros(shape=(480, 640, 3), dtype=np.uint8)

# this keeps the original image data around
imgref = img

while True:
    time, img = cvSink.grabFrame(img)

Bug report references:

Thank you, I’ll try it tomorrow

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.