Using a simple pipeline to exercise/test hailopython fails. Using the following pipeline
gst-launch-1.0 videotestsrc ! hailopython module=b.py ! autovideosink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Fatal Python error: init_threadstate: thread state already initialized
Python runtime state: initialized
Thread 0x00007fff3bddcbc0 (most recent call first):
<no Python frame>
Aborted
(venv_hailo_rpi5_examples) root@percy:/home/pi/exp# gst-launch-1.0 videotestsrc ! hailopython module=b.py ! autovideosink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Fatal Python error: init_threadstate: thread state already initialized
Python runtime state: initialized
Thread 0x00007ffeefd30bc0 (most recent call first):
<no Python frame>
Aborted
b.py is a simple test python script
import hailo
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst
def run(buffer: Gst.Buffer, roi: hailo.HailoROI):
print("My first Python postprocess!")
@sanjoyg the run function shouldn’t have an roi argument. Not sure if this is the cause of the error you are seeing, but please give it a try without it.
Also make sure to add a return Gst.FlowReturn.OK
nina-vilela:
Gst.FlowReturn.OK
Same result, modified code to be
mport hailo
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst
#def run(buffer: Gst.Buffer, roi: hailo.HailoROI):
#def run(buffer: Gst.Buffer):
def run(buffer):
print("My first Python postprocess!")
return Gst.FlowReturn.OK
Output
gst-launch-1.0 videotestsrc ! hailopython module=b.py ! autovideosink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Fatal Python error: init_threadstate: thread state already initialized
Python runtime state: initialized
Thread 0x00007fffa05f0bc0 (most recent call first):
<no Python frame>
Aborted
A paste error, read the first line as import hailo not “mport hailo”
@sanjoyg thanks for trying it out.
We reproduced the issue and we are checking what could be causing it, we’ll keep you updated
@sanjoyg we have noticed that the issue only happens when running the element using gst-launch.
While we work on a solution, you can add the hailopython to a GStreamer pipeline with Python on top.
For example, on the detection basic pipeline, you can add it as follows:
Thank you for reporting the issue to us, we will update here once it is solved.
manasa
November 14, 2024, 6:03am
7
jkrpi5@jk:~/tappas-3.29.1/apps/h8/gstreamer/general/multistream_detection $ GST_DEBUG=3 gst-launch-1.0 -v videotestsrc ! hailopython module=/home/jkrpi5/my_module.py qos=false ! autovideosink
Setting pipeline to PAUSED …
0:00:00.048556180 4409 0x555610774470 WARN xcontext xvcontext.c:546:gst_xvcontext_check_xshm_calls: MIT-SHM extension check failed at XShmAttach. Not using shared memory.
0:00:00.074478352 4409 0x555610774470 WARN xcontext xvcontext.c:546:gst_xvcontext_check_xshm_calls: MIT-SHM extension check failed at XShmAttach. Not using shared memory.
Pipeline is PREROLLING …
0:00:00.253201752 4409 0x5556104a7000 FIXME default gstutils.c:4031:gst_pad_create_stream_id_internal:videotestsrc0:src Creating random stream-id, consider implementing a deterministic way of creating a stream-id
Fatal Python error: init_threadstate: thread state already initialized
Python runtime state: initialized/GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0.GstPad:src: caps = video/x-raw, format=(string)I420, width=(int)320, height=(int)240, framerate=(fraction)30/1, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
Thread 0x00007ffec34b8c00 (most recent call first):
Aborted
Can you please help me out
It’s pretty old thread, is there any progress? I’m also getting:
Fatal Python error: init_threadstate: thread state already initialized
Python runtime state: initialized
Thread 0x00007ffecbbd9c40 (most recent call first):
<no Python frame>
Aborted
Using the code from the Python Module Template
giladn
March 13, 2025, 6:27am
9
Hi, the hailopython element should work if the pipeline is initiated from python. I.e. not from bash. See examples in our examples GitHub GitHub - hailo-ai/hailo-rpi5-examples
Please consider using our examples and adding you python code using a user callback. This works and tested. The hailopython plugin might be deprecated soon.