unable to read memory
I use opencv 3.1.0 and have a function at myClass.cpp below;
void initialize(Mat frame);
and i call the function from main like;
myClass temp = myClass::myClass();
temp.initialize(current_frame);
constructer works and assigns correct values to temp also current_frame is initialized and its values are correct at main class but when i call the function the program breaks and when i debugged i saw at myClass.cpp the function cannot read the values of frame as i give the parameter to the function. At the inside of initialize(Mat frame) it says "unable to read memory" for all parameters of frame(e.g size, coloumns, rows ...).
any help or suggestion?
Edit: I added a sample code that i get the same error below;
Main.cpp
#include "Modifier.hpp"
using namespace cv;
using namespace std;
Mat image;
int main(int argc, char* argc){
string imageName("../image.png");
if (argc > 1) {
imageName = argv[1];
}
image = imread(imageName.c_str(), IMREAD_COLOR);
if(image.empty()){
cout << "image is empty" << endl;
return -1;
}
Modify mdf(image);
if(mdf.getImage().empty()){
cout << "image is empty" << endl;
return -1;
}
// recently added line
mdf.myFunc();
}
Modifier.cpp
#include "Modifier.hpp"
using namespace cv;
Modify::Modify(Mat img){
this->image.upload(img);
}
GpuMat Modify::getImage(){
return this->image;
}
//recently added line
void Modify::myFunc(){
}
Modifier.hpp
#include <opencv2\core.hpp>
#include <opencv2\highgui.hpp>
#include <opencv\imgcodecs.hpp>
#include <opencv2\imgproc.hpp>
#include <opencv2\core\cuda.hpp>
using namespace cv;
using namespace cv::cuda;
class Modify
{
public:
Modify(Mat img);
GpuMat getImage();
//recently added line
void myFunc();
protected:
GpuMat image;
since it is unable to read the frame's values cannot assign values to parameters. hope it helps.
your code is a bit incomplete, we don't see, what happens inside
void initialize(Mat frame);
could you update it ?
I am not allowed to copy the code but i can say that the error occurs at the beggining of the function; first line is "vidSize = current_frame.size();" and cannot even execute this line.
then, how can we help you ?
try to make a minimal example, (without copying anything)
what is
current
?sorry, i missed out.
current
is one of the global variables of myClass, its type isGpuMat
. If you need more info i can provide as much as i am able toPlease, either add your code here or either accept that people cannot help out. How can we figure out errors if your not allowed to add a minimal code sample containing the error ...
BTW is there a reason why you have a seperate initialize function and you just don't initialize everything in the constructor of the class? It could be reduced to
myClass temp = myClass::myClass(current_frame);
fairly easy. Also, I suggest you to make clones of the data to ensure that it is not some sketchy pointer accessing problem ...initialize() method is for initializing another features of the object and runs some different algorithms, i've just name it as initialize. Sorry for the mess, i'm editing the code, writing a sample that i get the same error.