How to handle opencv gpu exceptions? Is there any specific set of error code api for opencvgpu exception handling?
I tried searching a lot but I only got 1 error code i.e. CV_GpuNotSupported.
Please help me out.
While I'm assuming that you know that CV_GpuNotSupported is NOT how OpenCV handles GPU exceptions, and in fact, it handles error when you try to call gpu methods without compiling OpenCV with -DHAVE_CUDA or -DHAVE_OPENCL, the way OpenCV (I also assume the newest OpenCV released version, 2.4.5) handles error codes, is defined in these files:
For methods that use NVIDIA CUDA:
https://github.com/Itseez/opencv/blob/2.4.5/modules/gpu/src/error.cpp
https://github.com/Itseez/opencv/blob/2.4.5/modules/gpu/src/precomp.hpp
For methods that use OpenCL:
https://github.com/Itseez/opencv/blob/2.4.5/modules/ocl/src/error.cpp
https://github.com/Itseez/opencv/blob/2.4.5/modules/ocl/src/precomp.hpp
As for the API, you can use cv::gpu::error or cv::ocl::error. Or to get the error string, getErrorString for cv::gpu and getOpenCLErrorString. And by the way for CUDA's error you have to specify whether it's an NPP, NCV, cufft, or cublas error.
Related
This is a problem I got when launching my own project,
OpenCV Error: Unsupported format or combination of formats (Gstreamer
Opencv backend doesn't support this codec acutally.) in
CvVideoWriter_GStreamer::open, file
/home/htf/Downloads/opencv-2.4.9/modules/highgui/src/cap_gstreamer.cpp,
line 505
Qt has caught an exception thrown from an event handler. Throwing
exceptions from an event handler is not supported in Qt. You must
reimplement QApplication::notify() and catch all exceptions there.
terminate called after throwing an instance of 'cv::Exception'
what(): /home/htf/Downloads/opencv-2.4.9/modules/highgui/src/cap_gstreamer.cpp:505:
error: (-210) Gstreamer Opencv backend doesn't support this codec
acutally. in function CvVideoWriter_GStreamer::open
Aborted (core dumped)
opencv version: 2.4.9
I am new to OpenCV, does anyone know how to fix this problem? Your clues would be appreciated too.
Looks like you passed an unsupported fourcc argument to the VideoWriter class.
The list of supported values of fourcc for CvVideoWriter_GStreamer in OpenCV 2.4.9 can be found at: https://github.com/opencv/opencv/blob/2.4.9/modules/highgui/src/cap_gstreamer.cpp#L462.
Just out of curiosity, why are you using a self compiled version of OpenCV?
When I run my code I get an error on this line:
personality = memory.readdwordunsigned(0x02024744)
This is the error message I am given by the console:
LuaInterface.LuaScriptException: [string "main"]:26: attempt to call field 'readdwordunsigned' (a nil value)
I have been doing some testing and researching around this for a while and I cannot get it to work despite this concept being used on several other projects such as this: https://projectpokemon.org/forums/showthread.php?16681-Gen-3-Lua-Scripts
Some other information:
1. I am running the lua script on the BizHawk emulator.
2. if I change the line to memory.readbyte() I receive a different message, which leads me to believe that the console does not recognise memory.readdwordunsigned() as a funciton.
3. The script is in the same folder as the executable file for the emulator.
Thank you in advance for any help
Turns out that support for memory.readdwordunsigned() is no longer supported in the BizHawk Emulator. After extensive research and help from a comment posted on my question I have managed to find a working alternative:
memory.usememorydomain("System Bus")
personality=memory.read_u32_le(0x02024744)
For anyone else who finds this answer useful, please note that a dword is unsigned and 4 bytes in size, hence the use of u32, because a dword is 32bits and unsigned. If you wanted to use a signed byte, for example, you would use s8 instead. le means little endien, be can be used instead for big endien.
It is important to state the memory domain before attempting to read from memory because the memory domain I was using (IWRAM) as well as all other memory domains except for the system bus would produce this error due to the size of the memory address.
In clang, is there a way to enable bounds checking for [] access to std::vectors and other STL containers, preferably when building in debug mode only?
I just spent hours hunting down a subtle bug that turned out to be caused by us accessing past the end of a std::vector. It doesn't need to do anything clever when it detects the error, just trap in the debugger so that I can find out where it happened and fix it in the code.
Is there a way to do this other than "create your own type that inherits from std::vector", which I'd like to avoid?
(I'm using clang version 3.1 if that makes a difference.)
libstdc++ has a mature debug mode using -D_GLIBCXX_DEBUG.
libc++ also has a debug mode using -D_LIBCPP_DEBUG but as we can see this mailing list discussion: Status of the libc++ debug mode it is incomplete:
| My understanding is that this work was never completed and it's
probably broken/incomplete.
That is correct.
It’s on my list of things to fix/implement, but it’s not something that I will get to anytime soon.
It does seem to work for std::vector on 3.4 and up see it live, give the following program:
#include <vector>
#include <iostream>
int main()
{
std::vector<int> v = {0,1,2,3} ;
std::cout << v[-1] << std::endl ;
}
it generates the following error:
vector[] index out of bounds
Aborted
If you're using Linux or OS X you should look into the address sanitizer:
http://clang.llvm.org/docs/AddressSanitizer.html
It introduces a 2x slowdown, but does a bunch of memory checking and may catch your bug.
Another amazing tool that has saved me countless times is valgrind. If you can run with valgrind it will catch a ton of memory bugs and leaks.
#define _GLIBCXX_DEBUG
This enables all kinds of inline checking (see vector and debug/vector)
For the life of me I can't figure out how to resolve the declared NTQueryKey value in my device driver. I looked for a device driver forum, but didn't find one.
Can someone point me to the right place? OSR isn't very responsive with dumb questions like how to link to NTQueryKey.
Here is my prototype:
NTSYSAPI NTSTATUS NTAPI NtQueryKey(HANDLE, KEY_INFORMATION_CLASS, PVOID, ULONG, ULONG *);
and it compiles fine, but the linker doesn't like it.
Thanks
NtXXXX functions should not be called from kernel mode. Use the ZwXXXX functions instead. In your case, you want ZwQueryKey. It has the same signature as NtQueryKey, but it performs actions on the x86 required for talking with kernel mode, and it's provided by ntoskrnl.exe rather than by ntdll.dll.
In kernel mode you link to the Zw.... equivalent functions. See Here. NT.... functions are called from user mode (for example the Win32 subsystem would call the NT... functions).
I am trying to do simple image processing with OpenCV and the cvBlobsLib in Visual C++ 2008, and I get an error message when I try to create a CBlobResult object
IplImage* original = cvLoadImage("pic6.png",0);
cvThreshold(original, original, 100, 255, CV_THRESH_BINARY);
CBlobResult blobs = CBlobResult(original, NULL, 255);
The message is the following:
Run-Time Check Failure #2 - Stack around the variable blobs was corrupted
Why does this happen? How should I create this object? Thank you very much for your help.
Sorry. Actually it was my fault. I was trying to compile the debug version of my project with the release version of the cvBlobsLib library. As soon as I linked the debug version it worked.