DetectNet with ROI

When I use the DetectNet to dectect the object, how can I use python to write detect in resion of interest ?
I modified jetson-inference/python/examples/detectnet.py but there is no response.
Where is the code to read and output the frame?

jetson-inference/detectnet.py at master · dusty-nv/jetson-inference · GitHub

Hi,

If you want to crop the input image before detection, you can modify the source code below:

Thanks.

You can also call the cudaCrop() function from Python without needing to modify the C++ source code: https://github.com/dusty-nv/jetson-inference/blob/master/docs/aux-image.md#cropping

After you modified detectnet.py, did you run it from jetson-inference/python/examples/ ? Otherwise you would want to run cmake ../ && make && sudo make install from your build dir so that your updates get installed to the system. What I actually recommend is making your own copy of detectnet.py and calling it something else to avoid confusion, since copies of detectnet.py get installed to jetson-inference/build/aarch64/bin and also /usr/local/bin, and it might be that you are actually running the previous version from before your edits.

Thanks, I can run it from jetson-inference/python/examples/
Which folder should I save the copy of detectnet.py to build ?

If you run cmake ../ from your jetson-inference/build directory, it will copy all the .py files under jetson-inference/python/examples to jetson-inference/build/aarch64/bin. And then when you run sudo make install it will install them under /usr/local/bin

You can save your own version of detectnet.py to any directory that you want to though.

1 Like

I can see that error as below after add “import cv2” in detectnet.py
Is there any solution?

“[cuda] device not ready (error 600) (hex 0x258)
[cuda] /home/ai/jetson-inference/build/aarch64/include/jetson-inference/tensorNet.h:754”

Hmm, can you try changing the ordering in which you import the modules to see if that has an effect? i.e. import cv2 after you import jetson_inference/jetson_utils (or vice versa)

Or if that doesn’t work, try import cv2 after you create the detectNet object.

Thanks, import cv2 after import jetson_utils is work.

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