Using OpenCV with gpu support in anaconda - opencv

I'm using Windows with a GTX 1050.
Currently I'm working with OpenCV in object detecting using yolo model. I found it's quite slow at ~7fps. I tried to install OpenCV with GPU support but it's only run when I execute the Python script in cmd, i mean not in Anaconda.
Is there any possible way to install OpenCV with GPU support?

Related

Does OpenCV 4.x dnn module has OpenCL support for NVidia or AMD GPUs

I am trying to run a DNN model using OpenCV on NVIDIA GPUs. Cuda works fine.
I am trying to run models using OpenCL:
network.setPreferableBackend(cv::dnn::DNN_BACKEND_OPENCV);
network.setPreferableTarget(cv::dnn::DNN_TARGET_OPENCL);
I got lower fps than the CPU. The task manager shows no increase in GPU usage.
Does the OpenCV dnn module utilize NVIDIA GPU if I select OpenCL?

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.

OpenCV 3.4 build with CUDA 9.1 on Windows - traincascade not use GPU

I builded OpenCV 3.4 with CUDA, Intel TBB, Intel MKL in VS 2015 like this
When I run traincascade for classifier training, 100% of CPU is used, but the GPU is not used 0%.
Does the OpenCV-traincascade use the functions of the library CUDA for calculations on the GPU?
No
https://devtalk.nvidia.com/default/topic/951477/jetson-tk1/are-tools-like-opencv_traincascade-gpu-accelerated-in-opencv4tegra-/
To train cascade is meant to be used as an offline tool to create a cascade detector, you should try using a powerful desktop system for training, and then use OpenCV4Tegra on Jetson to run the trained classifier on the device.
There is a CUDA accelerated version of the cascade training tool available in the Ubuntu Desktop x64 version of the OpenCV4Tegra package, which can be downloaded here:
http://developer.nvidia.com/embedded/dlc/l4t-24-1-opencv4tegra-ubuntu
Which sums it up more eloquantly than I could.
Also No - answered here
In Summary
The opencv_traincascade functionality is not developed using GPU code, for reasons I do not know. This tool however is meant to be run offline, and then the results from this training used in your actual detection run-time code which can be GPU optimised.

OpenCV 2.4.6 crash at program runtime

I have compiled OpenCV 2.4.6 on my Raspberry Pi using the Sourceforge repository. I used the following commands to install it:
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.6/opencv-2.4.6.tar.gz
tar zxvf opencv-2.4.6.tar.gz
cd opencv-2.4.6
cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_PERF_TESTS=OFF -DBUILD_opencv_gpu=OFF -DBUILD_opencv_ocl=OFF
make install
I get no errors when I compile. I am using the Face Recognition API to recognize faces from video captured through the Raspberry Pi camera module. I am using a C++ API called RaspiCam to capture frames from the camera, and it is compatible with OpenCV, allowing you to save captured frames as an OpenCV Mat object. The documentation for the API is at http://www.uco.es/investiga/grupos/ava/node/40. The source code for building the RaspiCam library is http://sourceforge.net/projects/raspicam/files/?source=navba.
Most of the time when I run my face recognition application, it runs fine. But every now and then, when I run my app it becomes unresponsive after an unpredictable amount of time with no error. Task Manager shows that the program is still running, but at a very small CPU usage like 2% instead of the usual 70-80% that it normally uses. I placed OpenCV try blocks for error handling to catch any OpenCV errors that may arrive, but none of them get invoked. I have noticed that my program crashes less often when I don't use the OpenCV highgui window to display frames, particularly if I run it through ssh. Has anyone had any similar problems?
I was experiencing the same problem with 'raspicam-0.1.1'. For me, downgrading the raspberry pi firmware resolved the problem.
sudo rpi-update 8660fe5152f6353dec61422808835dbcb49fc8b2
I found this firmware version mentioned when I was browsing the RPi-Cam-Web-Interface

Getting webcam to work in OpenCV 2.3 with Cygwin

I have a problem trying to get a webcam in OpenCV 2.3 to work with Cygwin. I have a Windows 7 64-bit system and I use Notepad++ and cygwin compilers to do my C++ programming. I have seen other posts with similar problems:
Getting Webcam to work in OpenCV
Can't access webcam with OpenCV
I first tried installing OpenCV via the Cygwin Ports. This is rather easy to install, but alas I run into the webcam problem (always returns false when trying to find a device). I have also attempted to build OpenCV and install manually using the command line flavor of CMake. I tried adding the HAVE_VIDEOINPUT and HAVE_DSHOW flags, but no dice. All my programs compile nicely and I have all the functionality of OpenCV aside for this webcam thing.
Has anyone successfully built OpenCV 2.3 on Cygwin with webcam working?
It is unlikely that cygwin build of OpenCV will be able to access a webcam. At least it is not possible without hacking OpenCV cmake scripts. Under cygwin OpenCV build always follows the UNIX branch and videoinput/directshow is excluded from build.

Resources