I recently switch opencv 2.4 to 3.1.0 version after since I am getting so many errors. So far I handled many of them but still there are so many.
Now, my code does not work when I try to run with opencv 3.1.0 but when I try debug it shows so many
First-chanace exception at 0x000007FEFD4CB16D in myProject.exe: Microsoft C++ exception: cv::Exception at memory location 0x.....
Unandled exception at 0x000007FEFD4CB16D in myProject.exe: Microsoft C++ exception: cv::Exception at memory location 0x.....
Some of this kind of errors disappeared by changing wrong includes to right ones but as i said still there are so many.
Here is the code which is related to exception;
Main.cpp
//class takes a video file and process it since i've checked i/o and the code is too long i've just skipped that part
//you can consider `frame` as a valid input.
#include
#include
#include "opencv2\opencv.hpp"
#include "cuda_runtime.h"
#include "MyClass.hpp"
using namespace std;
using namespace cv;
using namespace cv::cuda;
MyClass myobj;
cudaStream_t *stream;
int main(int argc, char** argv){
myobj = MyClass::MyClass();
Mat frame(720, 1280, CV_8UC3);
stream = new cudaStream_t[myObj.cnt];
for(int i = 0; i< myobj.cnt; i++){
cudaStreamCreate(&stream[i]);
}
myobj.func(frame);
while(1){
.
.
.
if((char)(waitKey(30)) == 27){
break;
}
}
for(int i = 0; i< myobj.cnt; i++){
cudaStreamDestroy(&stream[i]);
}
return 1;
}
MyClass.cpp
#include "MyClass.hpp"
using namespace cv;
MyClass::MyClass(){
gft_gpu = GFTTDetector::create(2000, 0.05, 5);
cnt = 2;
}
void MyClass::func1(){
(*gft_gpu).detect(cur_gray, keyp);
}
uint8_t *MyClass::func(Mat frame){
current.upload(frame);
func1();
}
Myclass.hpp
#include
#include
#include
#include
#include
#include "opencv2\cudafeatures2d.hpp"
#include "opencv2\cudaimgproc.hpp"
using namespace cv;
using namespace std;
using namespace cv::cuda;
class MyClass{
public:
MyClass();
uint8_t *MyClass::func(Mat frame);
void MyClass::func1();
protected:
int cnt;
GpuMat current, cur_gray;
vector> keyp;
Ptr gft_gpu;
}
I am not allowed to copy to whole code also it includes so many unrelated classes therefore I wrote the related part. When debugging at the main class `myobj.func();` program throws the exceptions and specifically it arises from `_images.getMatVector(images)` inside the `(*gft_gpu).detect(cur_gray, keyp);` at feature2d.hpp (according to call stack)
p.s. I am curious about one more issue i used to reference myclass object's variables by using`this->` at MyClass.cpp when using opencv 2.4 and it worked fine but now they caused some problems and I had to delete all of them then the problem thet they caused disappeared. Is it inappropriate using `this->` at opencv 3.1.0 ?
any advice? thanks.
↧