paul-pias / Object-Detection-and-Distance-Measurement

Using yolov3 & yolov4 weights objects are being detected from live video frame along with the measurement of the object from the camera without the support of any extra hardware device.
348 stars 118 forks source link

Nvidia nano #17

Closed mostafarahim closed 4 years ago

mostafarahim commented 4 years ago

Can i use NVIDIA Jetson nano for this project? And if yes , what are the requirements and the changes for this repo? Thank you in advance.

paul-pias commented 4 years ago

Sorry for the late response. Yes, you can use NVIDIA Jetson nano but you might face problems while installing the dependencies as Jetson as different hardware architecture(ARM) so in most cases, there is no official support for Libraries. But you will find 3rd party compiled libraries in different sources. However, you may find the following link useful as it has the wheel for torch-1.4 for both Jetson and Raspberry PI and instruction for installing OpenCV.

Pytoch & Jetson - Torch&OpenCV

Note:- I prefer RPI over Jetson.

mostafarahim commented 4 years ago

Thank you very much sir for your efforts😍 actually i have the both but as you told me before that it won’t work on the raspberry pi i started using the nvidia nano but i face many problems on it , actually i have the raspberry pi and the raspberry pi camera v2, the project will work on it now fine with out facing problems and specially after the changes you’ve made through the code or iam understanding wrong?

paul-pias commented 4 years ago

No, I guess you are doing fine. Just a suggestion, you should learn how to run python scripts in c/c++, I mean instead of a traditional python compiler GCC will execute your work. Try searching how to cythonize(Cython version of Python) python code. You will get huge performance enhancement in RPI/Jetson as in c++ there is no GIL. And try changing the object detector(yolov3) as there are few better Object Detectors are around now such as Detectron, YOLOv4 etc. You can also use Yolact.

mostafarahim commented 4 years ago

Thank you so much sir , installed already opencv and all libraries and followed your steps for the raspberry pi 3 b, but when i run i found this error: (python:3527): GStreamer-CRITICAL **: 14:01:20.247: gst_element_get_state: assertion 'GST_IS_ELEMENT (element)' failed

paul-pias commented 4 years ago

Have you installed opencv from source? Can you see the information using cv2.getBuildInformation() from the terminal to see if gstreamer is enabled or not. If yes, then you have to capture the video feed using gstreamer pipeline. You will find enough documentation on this.

mostafarahimtaha commented 4 years ago

i wrote it down and nothing happened (cv) pi@raspberrypi:~ $ cv2.getBuildInformation()

moreover another error found :

python /home/pi/Downloads/Object-Detection-and-Distance-Measurement-master/object_detection.py Traceback (most recent call last): File "/home/pi/Downloads/Object-Detection-and-Distance-Measurement-master/object_detection.py", line 161, in ObjectDetection(id).main() File "/home/pi/Downloads/Object-Detection-and-Distance-Measurement-master/object_detection.py", line 95, in init self.model.load_weights(self.weightsfile) File "/home/pi/Downloads/Object-Detection-and-Distance-Measurement-master/darknet.py", line 401, in load_weights weights = np.fromfile(fp, dtype = np.float32) MemoryError: Unable to allocate 237. MiB for an array with shape (62001757,) and data type float32

paul-pias commented 4 years ago

From your Python code you need to import cv2 first then print in the following manner- import cv2 print(cv2.getBuildInformation()) It will give you the details of your OpenCV installation. For your previous issue related to Gstreamer, you have to find the line, GStreamer: YES. If the tag is NO instead of YES then you have problem with your OpenCV installation. And if it's YES then try the Gstrramer pipeline for capturing feed.

And for the MemoryError issue try checking, if you are utilizing GPU memory or not. If yes kindly check the memory allocation progress from the Task Manager.