Using SURF in openv fails because of write access violation - image

I am trying to find the position of an image in another image using SURF, but every time I try to initialize the detector, it fails, telling me that there was an access violation and that detector.Ptr was "0xFFFFFFFFFFFFFF".
My code:
auto detector = cv::xfeatures2d::SurfFeatureDetector::create();
detector->detect(map,keypointsMap);
detector->detectAndCompute(compare, noArray(), keypointsCompare, descriptorComp);
This happens even when i use the example code from the opencv documentation (https://docs.opencv.org/3.4/d7/dff/tutorial_feature_homography.html). I can use the other non-free features like SIFT without any problems.
I am using opencv4 and I am including the following libraries:
#include "opencv2/core.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/xfeatures2d.hpp"
#include "opencv2/xfeatures2d/nonfree.hpp"
#include "opencv2/imgproc.hpp"
Has anybody seen this issue before and maybe knows a solution?
Thank you

I have found the problem, when I reinstalled opencv on my laptop. It seems that you have to configure cmake the right way (specify path for modules and allow nonfree) when you build opencv the first try to get SURF and SIFT to work. If you don't, you can't fix it by overwriting the old files. SIFT will work then, but not SURF, for some reason. So I deleted everything on my PC and then did the configuration right from the start and now it works. Oh, and also make sure you add everything to the path correctly.
Extremely useful description to install opencv on windows 10: https://www.youtube.com/watch?v=x5EWlNQ6z5w
Thank you Grillteller and everyone who read this!

Related

How to use iostream in VxWorks?

I am developing programs for VxWorks using Tornado 2.2. I meet some problem when I try to use cout. My code is here:
#include <iostream>
using namespace std;
void main()
{
cout << "Hi" << endl;
}
The project can be compiled without error. But when I try to download the .out file to the target machine (mounted on VMware), I got the following error:
What's the problem and how to solve it?
The problem is you are missing the appropriate library in the kernel configuration. To rectify this, you will need to add the correct component to the kernel configuration.
At the least, you will need to add INCLUDE_CPLUS_IOSTREAMS, however this might also require other components, possibly one or more of INCLUDE_CPLUS, INCLUDE_CPLUS_DEMANGLER or INCLUDE_CPLUS_LANG, dependant on what is already included.
If you are using the tornado GUI to configure your kernel, you can just browse through the tree - I can't remember the exact location in Tornado, but is fairly near the top - probably under C++ Components.
If you are using the command line to make your project, you may need to edit config.h directly.
That's some old tech you got there... Check you kernel configuration for various CPLUS options - you're missing something.

In what header is copy_from_user() declared?

Can anyone please help me with getting the proper header files needed for the copy_from_user method?
I found a few of the include headers I need, but my compiler keeps saying that they are not found. I am running CentOS on my machine. I have tried yum installing various kernel-headers and devel packages but still no luck.
Is there a special segment I need to add in my gcc command? Everything I find on the Internet only tells me how to use the method but not actually how I can get access to it in the first place.
I assume you're developing a kernel module, because outside of it trying to use copy_from_user wouldn't make sense. Either way, in the kernel use:
#include <linux/uaccess.h>
Edit: if building a kernel module is what you want, you may want to look at this Hello World Linux Kernel Module. Specifically the makefile portion may be of interest to you (search for obj-m).

Bad syntax include in Minix

I am developing a project for Minix in C Language and I have a folder to put the drivers of the devices called core. In the main.c I did an include of the vbe.h that is inside this folder and the make give me allways an error of bad syntax.
I tried two ways:
#include "./core/vbe.h"
#include "core/vbe.h"
I have always an error!
Can anyone help me?
Just so that the internet knows, I got this error and solved it. I believe I understand the reason as well.
I had used an array within a file which was not initialized. When I noticed this and commented the array out, it compiled fine.
My reasoning for the wording of the error is that it assumed I wanted to include this array, and that I forgot to include another file. So annoying.

How can I control the way gcc/g++ automatically includes headers?

I've run into trouble in the past when I've tried porting some C++ code written on Mac OS X to a Linux system, or trying to compile code written against an older version of gcc/g++ with a newer one:
It seems that some (older?) versions of gcc/g++ would automatically include some header files for you.
For example, code that uses printf should require #include <stdio.h>. And code that uses memcpy should require #include <string.h>. But depending on the version of gcc I'm using, it will occasionally include these for me.
It wreaks havoc when I forget to include something and then never get errors until I go to compile the code on another system. At that point it's a game of running all over the project and fixing the includes.
Has anyone else run into this? Is there a way to force gcc to autoinclude or to not autoinclude? Or, is there a way to know what it's autoincluding?
-include file
Process file as if #include "file" appeared as the first line of the primary source file. However, the first directory searched for file is the preprocessor's working directory instead of the directory containing the main source file. If not found there, it is searched for in the remainder of the #include "..." search chain as normal.
If multiple -include options are given, the files are included in the order they appear on the command line.
http://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html
Are you sure it's not other headers pulling those one's in, and on the other platforms not doing so?
When compiling on different systems, you might meet different problems and not only includes.
I would suggest investing in a continuous build system that will compile on all OS you need after each update of the code, so you are rapidly aware of any portability issue.
You can also put all common system header files inside a specific header file you will write and systematically include it in all your files.

iostream.h, fstream.h cannot be found

I have a 32 bit machine and I am running Ubuntu 9.10 on it. I have the latest gcc compiler. The problem that I am facing is that I have a library developed in 2002. The code is correct for sure but when I try to built it, it gives me errors like iostream.h cannot be found, error: fstream.h: No such file or directory etc etc. There are lots of files hence I cannot change them.
Can these errors be solved if solved I install gcc 3.0 ? If yes how to install it over my existing gcc compiler.
You're dealing with a pre-standard C++ library, and you've seen it won't compile with a standard compiler. You can always try the quick work-around by creating, say, iostream.h with the two lines #include <iostream> and using namespace std;, and that may work. It isn't reliable, and may cause hard-to-find bugs that will appear at an inconvenient time.
If this is a library from somewhere else, you could see if it's been updated.
The thing to realize is that the code isn't correct anymore. It may have been correct for some implementation at some time, but it isn't now. (Are you sure it was originally for gcc 3.0? Pre-standard compilers were, well, not standard, and had a lot of oddities. Avoiding that is what standards are for.) If you do install the original system, you may be unable to interface with the library properly, and new code isn't going to work. A library that doesn't interface with modern code is of limited use.
Otherwise, you're going to have to abandon the attitude that you can't change the library, and convert it to standard C++. There will likely be quite a few bugs that are fairly easy to fix (like the scope in for (int i = 0;...)), and may be some subtler problems. The code may have been correct for a certain compiler, but it isn't now.
The fstream.h and similar files are pre-standard versions of the fstream and similar files specified by the C++ Standard that come with modern compilers. The two are not typically compatible. Frankly, if no-one has updated the library to comply with the standard in the last 8 years, it is unlikely to be worth using.
Why couldn't you write a script to search and replace all instances of
#include <iostream.h>
with
#include <iostream>
And the same for the others?
Update:
I agree with the other answer, and the comments below... I'll leave this answer though because I don't think the statement
There are lots of files hence I cannot
change them
is valid :)

Resources