Posted by Hemprasad Y. Badgujar on July 17, 2015
OpenCV GPU module is written using CUDA, therefore it benefits from the CUDA ecosystem. There is a large community, conferences, publications, many tools and libraries developed such as NVIDIA NPP, CUFFT, Thrust.
The GPU module is designed as host API extension. This design provides the user an explicit control on how data is moved between CPU and GPU memory. Although the user has to write some additional code to start using the GPU, this approach is both flexible and allows more efficient computations.
GPU modules includes class cv::gpu::GpuMat which is a primary container for data kept in GPU memory. It’s interface is very similar with cv::Mat, its CPU counterpart. All GPU functions receive GpuMat as input and output arguments. This allows to invoke several GPU algorithms without downloading data. GPU module API interface is also kept similar with CPU interface where possible. So developers who are familiar with Opencv on CPU could start using GPU straightaway.
In the sample below an image is loaded from png0file, next it is uploaded to GPU, thresholded, downloaded and displayed.
int main (int argc, char* argv)
cv::Mat src_host = cv::imread("file.png", CV_LOAD_IMAGE_GRAYSCALE);
cv::gpu::GpuMat dst, src;
cv::gpu::threshold(src, dst, 128.0, 255.0, CV_THRESH_BINARY);
cv::Mat result_host = dst;
catch(const cv::Exception& ex)
std::cout << "Error: " << ex.what() << std::endl;
Posted in Mixed | Tagged: CUDA, GPU, GPU module API interface, OpenCV | Leave a Comment »
Posted by Hemprasad Y. Badgujar on January 25, 2015
Depending on what I am doing and what I need to track/trace and profile I utilise all 4 packages above. They also have the added benefit of being a: free; b: well maintained; c: free; d: regularly updated; e: free.
In case you hadn’t guessed I like the free part:)
In regards of object management, I would recommend an old C++ coding principle: as soon as you create an object, add the line that deletes it, every new should always (eventually) have a delete. That way you know that you are destroying the objects you create, however it will not save you from orphaned memory block memory leaks, where you change where pointers are pointing, for example:
myclass* firstInstance = new myclass();
myclass* secondInstance = new myclass();
firstInstance = secondInstance;
You will now have created a small memory leak where the data for the real firstInstance is now not being pointed at by any pointer. Very hard to detect when this happens in a large code-base, and more common that it should be.
generally these are the pairings you need to be aware of to ensure you properly dispose of all your objects:
new -> delete
new -> delete
malloc() -> free() // or you can use realloc(0) instead of free()
calloc() -> free() // or you can use realloc(0) instead of free()
realloc(nonzero) -> free() // or you can use realloc(0) instead of free()
If you are coming from a language with garbage collection to C++ it can take a while to get used to, but it quickly becomes habit:)
Posted in C, Computer Languages, Computer Vision, Computing Technology, CUDA | Tagged: c projects with source code download, Computer Vision, CUDA, GPU, Nvidia NSight, OpenCV | Leave a Comment »
Posted by Hemprasad Y. Badgujar on January 3, 2014
Installing CUDA Toolkit 5.5 on Ubuntu 12.10 Linux
The following explains how to install CUDA Toolkit 5.5 on 64-bit Ubuntu 12.10 Linux. I have tested it on a self-assembled desktop with AMD Phenom II X4 CPU, 4GB RAM, 500GB hard drive, 650W power supply, and NVIDIA GeForce GTX 550 Ti graphics card. The instruction assumes you have the necessary CUDA compatible hardware support. Depending on your system configuration, your mileage may vary.
Retrieve the CUDA repository package for Ubuntu 12.10 from the CUDA download site and install it in a terminal.
$ sudo dpkg –i
$ sudo apt-get update
Linux Kernel Header
Then you need to install the necessary Linux kernel headers.
$ sudo apt-get install linux
Proprietary Video Driver
The built-in nouveau video driver in Ubuntu is incompatible with the CUDA Toolkit, and you have to replace it with the proprietary NVIDIA driver.
$ sudo apt-get remove –purge \
$ sudo apt-get install nvidia
You can reboot the system afterwards and verify the driver installation with the nvidia-settings utility.
Then you can install the CUDA Toolkit using apt-get.
$ sudo apt-get install cuda
As part of the CUDA environment, you should add the following in the .bashrc file of your home folder.
CUDA SDK Samples
Now you can copy the SDK samples into your home directory, and proceed with the build process.
If everything goes well, you should be able to verify your CUDA installation by running thedeviceQuery sample in bin/linux/release.
Posted in Computer Languages, Computing Technology, CUDA, GPU (CUDA), PARALLEL | Tagged: GPU, GPU Computing, Security, Ubuntu, Ubuntu Software Center, Universal Studios | Leave a Comment »
Posted by Hemprasad Y. Badgujar on May 29, 2013
P0212 GPU Acceleration In Multilayer Parallel User Authentication Schemes By Optimizing Hardware Use
Hemprasad Badgujar (Hardsoft)
Posted in Mixed | Tagged: Authentication, GPU, GPU Computing, parallel computing, Security | 1 Comment »