OpenCV. FisherFace "model->predict" - c++

First time question here, tx in advance.
I am trying to use code from opencv tutorial that use the fisherface algorithim.
I am able to create the fisherface model and train it,detect faces but fail on the recognition part model->predict.
I am also pretty new to C++ and trying to debug this problem myself but I guess I still need help here.
Jumping in at line model->predict(face_im)
I get to the following line of code in operations.hpp and fail immediately without any description of the error.
template<typename _Tp> inline _Tp* Ptr<_Tp>::operator -> () { return obj; }
executing this line jumps back out to the main and breaks with error
Access violation reading location 0x00000019.
agh, I hope this is not to vague but how can i analyze my problem here?
Again tx in advance and if more info is needed ..sure thing
Et

I've come to a conclusion; it was a scoping problem. By moving the declaration out of main, I was able to get it to work fine.
I guess it was very vague. It's still a bit unclear to me, but I suppose I need to brush up on my C++.

Related

Alternative of CreateVideoSource() in webrtc

Hi all I had seen one webrtc old source code which has this method called CreateVideoSource() for adding streams after an CreateAudioTrack() call.
rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> video_source =
peer_connection_factory_->CreateVideoSource(std::unique_ptr<cricket::VideoCapturer>(
media_source->GetVideoCapturer()),
NULL);
What's happening is whenever I try to build it gives an error for the above CreateVideoSource() that it is undefined. And the reason behind that is the latest webrtc-checkout has deprecated this.
So my question is, I wanted to know the alternative which they have introduced after deprecating this method. So can anyone tell me what the alternate approach is.
Okay, Finally I was able to come up with an alternative(i.e the current implementation of libwebrtc) after looking into bundle examples and tests.
Line 71 is a good point to start

Implementation of active appearance models

I'm having an internship in the field of computer vision, and i am really interested to know some details about the implementation of the Active Appearence Models aam-opencv that exists in the Google Code site.
In fact, i downloaded aam-opencv.tar.gz then built it with cmake and i solved some syntax problems but the only error that i am still having when i try to generate the solution is the following :
This function should return something:
aamImage* delaunay:: warpImageToMeanShape(aamImage*input)
{
}
I wonder if there is something missing in that function, or is it a compiler problem.
Please give me an answer or just guide me to complete the missing part of that function.
I would really appreciate if anyone kindly help me.
Thank you.
I suppose that is not used in code function, so it is not important what it return. Some C++ compilers allow to write such code and give only warning, another treat as errors:
ReturnType f()
{
}
looks like you use not the same compiler as author of source code. So just add something like:
aamImage* delaunay:: warpImageToMeanShape(aamImage*input)
{
return NULL;
}

How do you call a function using self in cocos2d 0.99.5

Yes I am a begginer. I am reading a book on cocos2d development. The author wrote this book using 0.99.4. In the book, it says to call a function that creates sprites and adds them to an array by using the following code: [self initSpiders];. But when I run this, I get a warning that says "'Gamescene may not respond to'-resetSpiders'". I am assuming that there is an updated way of doing this in the newer version of cocos2d. If there is, I would be thankful if someone could explain the proper way of going about this. If this is the correct way, then what am I doing wrong? Thanks in advance.
In objective-c, an object tells a message to do something:
[someObject doSomething];
Or with an argument:
[someObject doSomethingWithArgument:someValue];
The message you get from the compiler is telling you that the object (eg. "someObject") does not understand what you are telling it to do (doSomething).
To make that compiler warning go away, check the following:
Did you #include the header file of the class your "someObject" is an instance of?
Does that header file in fact have the method you are calling? (including arguments?)
If you are calling a method you wrote, make sure you put that method in the header file. If you are calling a method that someone else wrote, or is part of the OS; make sure you include the header file, then perhaps find the method in the header file and copy/paste it into your code. This will make sure you get the EXACT method signature. These two are not the same:
[self generateSprites]; // note the capitol S
[self generatesprites]; // method names are case sensitive
If you need a better answer, you'll need to post some of your code so that people can see what you're doing wrong.

What has to be Glib::init()'ed in order to use Glib::wrap?

So I'm trying to make use of a GtkSourceView in C++ using GtkSourceViewmm, whose documentation and level of support give me the impression that it hasn't been very carefully looked at in a long time. But I'm always an optimist :)
I'm trying to add a SourceView using some code similar to the following:
Glib::RefPtr<gtksourceview::SourceLanguageManager> source_language_manager = gtksourceview::SourceLanguageManager::create();
Glib::RefPtr<gtksourceview::SourceLanguage> source_language = Glib::wrap(gtk_source_language_manager_guess_language(source_language_manager->gobj(), file, NULL));
Glib::RefPtr<gtksourceview::SourceBuffer> source_buffer = gtksourceview::SourceBuffer::create(source_language);
gtksourceview::SourceView* = m_source_view = new gtksourceview::SourceView(source_buffer);
m_vbox.pack_start(*m_source_view);
Unfortunately, it spits out the warning
(algoviz:4992): glibmm-WARNING **:
Failed to wrap object of type
'GtkSourceLanguage'. Hint: this error
is commonly caused by failing to call
a library init() function.
and when I look at it in a debugger, indeed the second line above (the one with the Glib::wrap()) is returning NULL. I have no idea why this is, but I tried to heed the warning by adding Glib::init() to the begining of the program, but that didn't seem to help at all either.
I've tried Google'ing around, but have been unsuccessful. Does anyone know what Glib wants me to init in order to be able to make that wrap call? Or, even better, does anyone know of any working sample code that uses GtkSourceViewmm (not just regular GtkSourceView)? I haven't been able to find any actual sample code, not even on Google Code Search.
Thanks!
It turns out, perhaps not surprisingly, that what I needed to init was:
gtksourceview::init();
After this, I ran into another problem with one of the parameter to gtksourceview::SourceLanguageManager, but this was caused by a genuine bug which I subsequently reported and was promptly fixed. So everything's working great now!
I use gtkmm. Typically you have to initialize things with something like :
_GTKMain = new Gtk::Main(0, 0, false);
Of course do not forget :
delete _GTKMain;
Check here for details :
http://library.gnome.org/devel/gtkmm/2.19/classGtk_1_1Main.html
(Sorry but the link option does not work ...)

class NSCFNumber autoreleased with no pool in place - just leaking

I am new to C++ and have just started to work on a project using threading.
Currently my project involves the OpenGL and OpenCV libraries, and in the process of coding I encountered the following error :
Current language: auto; currently c++
2009-12-21 14:54:49.438 3DTestApp[3210:7803] *** _NSAutoreleaseNoPool(): Object 0x10ebe0 of class NSCFNumber autoreleased with no pool in place - just leaking
Stack: (0x91edff4f 0x91dec432 0x941ad394 0x94282218 0x94281b32 0x94528023 0x942813ef 0x94280dc6 0x94489ef4 0x944882ab 0x9350e13d 0x9350d57b 0x9350d3e0 0x93529e29 0x93529bce 0x935292a8 0x935290e4 0x5743e2)
kill
quit
I put breakpoints and realised the error occurred only after the following line was executed:
cvShowImage("Motion Tracker", detectionMotionScreen); (this code was in a thread with infinite loop)
I have googled around and realised that this error only occurred in Objective C, and I found no results related to C++.
As such, I would wish to ask if anyone has any idea why has this occurred, and is there anyway to fix it?
edit : I have tried adding the framework Foundation to use NSAutoreleasePool, however upon compiliing it generates alot of errors in my codes with regards to the syntax, when actually there were none.
Apple doesn't have any public interfaces written in C++ outside of IOKit, so you're not going to find any. The procedural C documentation on CoreFoundation memory management is here.
If you want more specific help then you're going to need to describe what it is you're doing a lot more thoroughly.