Tiny yolo v4 dnn module opencv no detection - opencv

I'have trained yolo-tiny-v4 on colab and the detection works well on colab.
Then I've tried to load the yolo-tiny-v4 in this way on visual studio integrated with Gazebo/ROS:
No error appears, but the detection fails (no object detected, the output of the detection is a vector of Nan).
I'm using OpenCV Version: 4.2.0 and Python 2.7.17 in visual studio.
Any idea?

Try compiling OpenCV >= v4.5.0 from sources.
Compiling version 4.5.0 from sources solved the issue for me in Python 3 and I checked it also works in Python 2.7.
I initially got the same issue with Yolo Tiny v4 and Python 3.7, both on Raspberry Pi 4 and Windows 7, with OpenCV installed via pip install opencv-contrib-python (seems not available for Python 2.7 ?).
I tried different versions iteratively, got from pip or recompiled from sources (latest version available via pip on Raspbian was 4.1.0.25):
opencv-contrib-python==3.4.10.37 no detections (tested on Windows)
opencv-contrib-python==4.1.0.25: no detections (tested on Rasbian Buster and Windows)
opencv-contrib-python==4.2.0.34: no detections (tested on Windows)
opencv-contrib-python==4.3.0.38: no detections (tested on Windows)
opencv 4.4.0 compiled from sources: no detections (tested on Rasbian Buster)
opencv-contrib-python==4.4.0.40: ok (tested on Windows)
opencv-contrib-python==4.4.0.46: ok (testd on Windows)
opencv 4.5.0 compiled from sources: ok (tested on Rasbian Buster)
Versions a little after opencv-contrib-python==4.4.0.40 seemed to works, so the "next" version available on Raspbian at the time was v4.5.0 from sources.

Related

Does a specific Python/C++ version need a specific openCV version?

I'm using python 2.7 in a ROS project with openCV 2.4.8 but this version of openCV doesn't have the barcode detection module. Can I update openCV using the same version of python (2.7) and still working?
I don't know if I can use any version of opencv regardless of the python version.
Thanks in advance

EasyOCR disables Cuda GPU when installed

Hello after installing EasyOCR via pip install easyocr via Anaconda Prompt (base) I receive this error.
OpenCV(4.5.4)
D:\a\opencv-python\opencv-python\opencv\modules\core\include\opencv2/core/private.cuda.hpp:106: error: (-216:No CUDA support) The library is compiled without CUDA
support in function 'throw_no_cuda'
Before installing easyocr, cuda is active and working with my GPU, but is disabled after installing EasyOCR.
I complied my build via Cmake using opencv4.5.4 and opencv-contrib4.5.4 with Cuda 11.3.1 and Cudnn 8.4.0 as well as uprading tot he most recent numpy 1.22.3.
It seems that after installing eascyOCR is changes my opencv build from whatever I am using to "opencv-python-headless-4.5.4.60" and that is I believe where the issues is at.
This is the version of easyocr installed.
Downloading opencv_python_headless-4.5.4.60-cp39-cp39-win_amd64.whl (35.0 MB)
Successfully installed easyocr-1.4.2 opencv-python-headless-4.5.4.60 python-bidi-0.4.2
Any idea or help on how I can get easyocr working with Cuda and my GPU?
Solved,
Have to install EasyOCR first
Then build OPENCV

getCudaEnabledDeviceCount() returning -1 : OpenCV [cuda] built with vcpkg

Building an OpenCV CUDA app on win10 with MSVC 2017 using the opencv[cuda] package installed by vcpkg. To check for usable devices, I call getCudaEnabledDeviceCount() and it returns -1, which OCV documents as meaning cuda support is enabled but the CUDA driver is incompatible.
Re-installing opencv[cuda] with vcpkg did not help.
Can you suggest a way to diagnose or fix?
Answer: The machine is an old gaming laptop whose most recent recommended nVidia display driver is 425.31. I had recently installed CUDA toolkit 10.2, whose runtime is actually incompatible with that driver. Rolling back to toolkit 10.1 resolved the problem.

Can't run Tensorflow-federated on GPU

I am trying to run my python code which uses tensorflow-federated on a GPU. To set up my environment, I use venv. First, I install tensorflow-gpu, and my python code then can recognize the GPU, I use tf.test.gpu_device_name(). However, as soon as I install tensorflow-fedenerated, my python stops seeing any GPU and starts using CPUs!!
I am using Ubuntu 16.04.6 LTS. I tried a plenty of combinations of different versions of the packages:
python = 3.6, 3.7
cuda = 10.0, 10.1
tensorflow-gpu = 1.13.1, 1.15, 2.1.0, 2.0.0-alpha0
tensorflow-fedenerated = 0.2.0, 0.12.0, 0.13.0
It's hard to say exactly what the problem is here, but I do have a suspicion.
TFF declares TensorFlow 2.1 as a required package; this may mean that your TF-gpu installation is being removed during the TFF installation setup.
Can you please try the following order:
Open a fresh venv
Install TFF
Uninstall TF
Install TF GPU 2.1.0

Using GPU in OpenCV

If I want to use my computer's GPU with OpenCV, is it necessary that I build OpenCV from source with CUDA enabled? Or can I install OpenCV with CUDA support via apt-get? I noticed the following 2 packages in apt-get:
libopencv-gpu-dev - development files for libopencv-gpu2.4v5
libopencv-gpu2.4v5 - computer vision GPU library
But I am not sure if these will work with OpenCV3 or if they are only compatible with OpenCV2. I know that the gpu module in Opencv2 was split up into multiple CUDA modules in OpenCV3.
Yes it is necessary that you build opencv from the source with CUDA option enabled. The apt-get packages won't work with OpenCV3 and above versions. I suggest you install the CUDA Toolkit first and then attempt installation of OpenCV or the GPU functions won't work.

Resources