plstcharles / litiv

C++ implementation pool for computer vision R&D projects.
http://www.polymtl.ca/litiv/en/
Other
101 stars 30 forks source link

Program crashes when testing litiv_sample_changedet #9

Closed ln1equals0 closed 7 years ago

ln1equals0 commented 7 years ago

Hi, I'm testing the library in MSVS2015.

When I run litiv_sample_changedet with some sample image sequences (build is all fine, no errors, no warning, build under Debug x64), the program crashes on this line..

f1

and the debugger brought me to this file and said illegal instruction (something related to the memory)

f2

How can I fix it? Or is there other way to get the instance of the background subtraction method. ( and BTW, when I compile the code using Release x64, the program crashes without running a single line of code, do i need some extra configuration?)

plstcharles commented 7 years ago

Hello!

It seems that for some reason, the app is crashing while trying to allocate a memory block under 'std::make_shared' in Debug. The PAWCS algo itself (before initialization) contains nothing exotic, so I feel like the error might be coming directly from MSVC. Try to fully rebuild the solution, and get rid of all libraries (statics & DLLs) that might be leftovers from other MSVC versions/builds. The error in Release might be due to the same thing.

On the other hand, you can try to bypass the 'make_shared' call, as the PAWCS algo constructor is public (the base class you're looking for is 'BackgroundSubtractorPAWCS_lv::NonParallel').

ln1equals0 commented 7 years ago

Hi, I reinstalled the MSVC 2015, redid the cmake, and fully rebuild the solution, and the all the dependencies I have is following, unbenannt

still the same error, what did I miss.

ln1equals0 commented 7 years ago

And can you please explain more how can I bypass the make_shared call exactly? Because I'm not very familier with the struct followed by angle bracket.

Can you please make an example how can I alternativlly get the instance e.g for SuBSENSE algorithm to variable pAlgo. Thanks very much!

plstcharles commented 7 years ago

The 'make_shared' call returns a 'shared_ptr' to a newly allocated object by doing the equivalent of this: std::shared_ptr<X> ptr = std::shared_ptr<X>(new x(...args)); ... where 'X' is the targeted object type, and '...args' are the parameters passed to 'make_shared'. In this case, since 'X' is some background subtractor algorithm type with a public constructor, you can create the algorithm directly on the stack, i.e.: BackgroundSubtractorSuBSENSE algo1; BackgroundSubtractorPAWCS algo2(2,20); On the other hand, you can keep the pointer-interface approach, and simply use: BackgroundSubtractorSuBSENSE* pAlgo3 = new BackgroundSubtractorSuBSENSE(); ... but you will then have to manually release the pointer when you're done.

If you get allocation problems again, could you screenshot the error message? I doubt it comes from the code, and it could help identify the issue.