OpenCV 2.4.4 and GPU support for face detection - c

I am using GPU for faster face detection. I have found an acceptable tutorial here. I am using VC10 compiler along with CUDA 4.2. The device is well installed and devicequery passes the tests. I also have written programs in CUDA which leaves me no choice but to say that OpenCV has problems with GPU. The real problem is an access violation when I try to get an instance of CascadeClassifier_GPU. Also, getCudaEnabledDeviceCount returns zero. I have compiled OpenCV with CUDA flag on and there was no serious problem during the compilation only a python interface failed which is absolutely non-relevant to GPU. Is there anyone out there who actually succeeded in running a face detection code with haar features on a GPU with OpenCV? Can you give me a hint about what I am missing?

The problem was with OpenCV CMake. The output directory is assumed to be the /build directory however once you check it, you see that all files in the /build are old. You should gather new dll and lib files from /bin and /lib. This is a major flaw in my opinion since many people will use the old files and think their compile was unsuccessful. Please also note that the CUDA version must be 4.2.9 both SDK and Toolkit once you are building the project. Now GPU module works just fine for me.

Related

Trying to solve WindowError 126 - module not found

Though this is my first question on the StackOverflow, I consider myself a long time member of the community.
Considering myself as a pre-intermediate programmer, I'll try to be as specific as possible.
I'm writing a Python package that uses a C dll to load image files with ctypes. I'm using Python 3.3.5 32bits version on Windows 8 x64. I had to build the dll from the C code. The dll is stb_image.h which is available in GitHub. I used Code::Blocks version 13.12 with the GCC compiler. The dll seems to have built fine.
By my definition, the dll is must be in the same folder as the py code file that wraps its functions, but when ctypes attempts to load the dll an exception is raised: the [in]famous WindowsError: [Error 126] Module not found.
I've found several similar questions and attempted to glean from their solutions by
adding the dll path via os.environ['PATH']
adding the dll path manually in the Path environment variable
changing the current working directory with os.chdir()
using the file module attribute to locate the library
none of these solved the issue
The stb_image library itself has no dependencies so I don't understand why windows can't find it since the dll is where it should be and the path addresses it's exact location. And, of course, there's a lot of other ways to get the job done: PyGame, pySFML (which also uses stb_image), PIL, PyPng, PySDL, you name it, but I'm doing this mostly for learning purposes.
At the writing of this question, something popped up in my head (which may or may not have any relation with the problem): whenever I compile and link programs with GCC and try to run them, I got a message box telling me that some dll (libgcc.dll or something like that) was not found. Could that be the reason Windows can't load stb_image.dll?
I tried everything my experience allowed me to do to solve it but it was not enough. Would you guys, please, give me a light on this?
PS.: Sorry for any bad english. I'm natural from Brazil.

Visual Studio 2012 with CUDA 5.5 - CUDA syntax & definitions not recognized

for a lab we're suppose to work on I need to set up Cuda with Visual Studio 2012 and run some tests. What I've done:
Install Cuda 5.5 + Edit build configurations.
Visual Studio 2012 is installed.
In the project, right click -> Build Configurations and choose Cuda 5.5
Project -> Properties -> VC++ directories: Set include/lib directories from Cuda directory.
Now, I was under the impression that after doing all this I should have no need to put "#include cudafiles" in my classes, they should be automatically imported, no?
I'm not getting the following as undefined:
cudaFree
cudaError
HANDLE_NULL
The following as 'device is not a type name'
__device__
And __global__ has no storage class or identifier.
I've spent hours and hours and hours trying to get this to work, following tutorials online, but I just can't get it to run properly. The code I'm using can be found here:
https://bitbucket.org/mrfright/cuda_by_example/src/bd759a6527ffa1b88420fc09acbc52f88c0587d2/appendix_a/?at=default
You can see in those files only 'lock.h' and 'book.h' are being included. I am including both of those.
Also, I am very new to C and VS so I may be leaving out a lot of important info.. please advice me to anything you may need to help assess this!! Thanks!
a few key points extracted from the discussion in the comments:
when installing CUDA on windows, make sure VS is installed first. The CUDA toolkit install modifies VS to make compiling CUDA code easier. If VS is not installed or you install/reinstall later, you won't get these modifications.
follow the instructions in the getting started guide including the running of sample projects followed by the building of sample projects. The first point at which you have trouble will be instructive as to what the actual problem is. If you just jump to the end (i.e. trying to create/build/run your own project), it won't be clear where the problem is.
You can build your own CUDA project either by opening an existing project and modifying it, or else creating a new project using the wizard. When just starting out, it may be easier for new users to try modifying an existing project first.
Be aware that various CUDA programs may require a specific compute capability. This means both that your device must support that compute capability, and that you are compiling correctly for that compute capability. You can determine the compute capability of your device by running the deviceQuery sample. You can change the compute capability that you are compiling for in the VS project CUDA settings.
when writing your own CUDA code, and definitely if you are having trouble, you should always do proper cuda error checking
Also be aware that asking questions about how to get drivers loaded, etc. and sorting out machine configuration issues, will very often be considered off-topic for stack overflow. Many questions like this get close votes for this reason.

OpenMP not in NetBeans IDE 7.0

The title is fairly self explanatory... isn't anywhere to be found in the version I have (the latest), and all searches on the web have turned up little to nothing in the way of real solutions. There is only a pdf file which explains that omp flags must be marked in the C compiler I use, but I can't even get that far because I can't find the library anywhere!
Is there just a way to pull the library from somewhere and load it in? Or do I need an entirely new gcc file for my IDE to pull from, and if so, where do I get it?
EDIT: Still no luck searching. I'm also willing to work with a different IDE similar to NetBeans... preferably one that uses the Cygwin compiler set as well. If anyone has any suggestions on what I could use that would support OMP, I would be more than willing to entertain them.
Oracle Solaris Studio on Solaris (SPARC and x86) and Linux (x86) provides an IDE with C/C++/Fortran compilers with OpenMP 3.0 enabled, and a debugger and performance analyzer that understand OpenMP.
http://www.oracle.com/technetwork/server-storage/solarisstudio/index.html
And, it's a free download and free to use.

Building standalone OCaml program

I'm getting crazy while trying to understand how to produce a binary in OCaml that doesn't need anything too specific (eg. having anything as OCaml build tools installed).
I'm using OMake and everything seems enough cool while working on my machine, also linking libs with
OCAMLPACKS[] = str unix batteries
works quite well, but if I try to distribute the executable it gives me the following error:
Fatal error: exception Sys_error("/usr/godi/share/camomile/database/general_category.mar: No such file or directory")
yes I'm using GODI but I don't see any apparent reason for this error, can anyone enlighten me? In addition, if you have any tricks regarding building stand-alone applications please tell me (I'm already arguing with GODI that compiled everylib just in its x64 version and now I'm unable to produce x86 executables)
Thanks in advance
The camomile library requires runtime configuration. See README.txt for informations about how to set it up.
In particular, it requires runtime files (the missing .mar you see) to correctly work.
I don't use OMake, neither batteries, neither GODI nor Camomile. But from what I see the problem seems to come from the fact that you link against Batteries which I guess must use Camomile internally and Camomile relies on data stored in the file system to provide some of its service. It fails to load if that data is not present on the final host.
Note that shipping purely static excutables is something that is fairly simple to do with OCaml. But for that you need to consider which libraries you use (e.g. if you use camomille you will have to ship the support files with).

How to start debugging?

I have learned C and I would like to start to improve open source software. I would like to hack away one irritating bug in GTK+. To see the bug I need to use Gedit.
How can I download the sources of GTK+ and gedit and compile both of them so that I can see where the bug is? And I have never used any debugger in Linux so is there somewhere a tutorial for that?
You can get information about downloading and compiling of gedit here:
http://projects.gnome.org/gedit/developers.html
My Debugger of choice is GDB:
http://www.gnu.org/software/gdb/
GDB is a console application that may be hard to handle for a beginner. Try an IDE like Eclipse that provides a GUI to GDB.
Almost all Linux debuggers are front-ends for or adaptations of the gdb debugger. You should therefore learn how to use this first, preferably by starting on
small programs of your own construction, not giant FOSS codebases. The gdb manual,
available from here is actually a pretty good tutorial.
The information on building and installing GTK+ should be here:
http://www.gtk.org/development.html
The sources should be here:
http://www.gtk.org/download-linux.html
You can check out gdb:
http://www.gnu.org/software/gdb/ That's a pretty standard linux debugger. I would spend time with it on something simple first, or get an IDE that uses it. Learning gdb can be worth the time though.
gdb is a dinosaur which should long since have been made extinct. Debugging is one area where (gasp!) Windows beats Unix. Having got that off my chest, I advise you to start with the Data Display Debugger (DDD) graphical front end to gdb. Yes, the GUI is quaint, but you will be far more productive, quicker, than if you start with gdb.
Also don't overlook valgrind for finding and diagnosing memory errors. The KDE project actually mandates use of valgrind; I'm not sure about Gnome.
It is possible that you won't see the bug if you download the latest gedit and gtk+ sources. It might be fixed in the latest sources or the latest sources might be different enough to not trigger your bug.
What Linux distribution are you running?
First of all I'd suggest consulting your distribution's bug database to see if someone has filed a similar bug. If you don't find anything, I'd suggest using your distribution's tools to obtain the source that corresponds to the binary that you have installed on your sytem (e.g. apt-get source libgtk-2.0 on Debian or Ubuntu).
Also, your distribution might also make a debug package available (e.g. libgtk2.0-0-dbg on Debian) which will let you run a debugger on the binary that you already have without requiring the source. While this is no substitute for having the sources, it can be useful for running valgrind or making sense out of a core file.

Resources