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:Edit:
I added a sample code that i get the same error below;
Main.cpp
.
.
#include <iostream>
#include <opencv2\core\core.hpp>
#include <opencv2\highgui.hpp>
#include <opencv\imgcodecs.hpp>
#include <opencv2\imgproc\imgproc.hpp>
#include "Modifier.h"
using namespace cv;
using namespace std;
Mat current_frame(numRows, numCols, CV_8UC3);
myClass temp image;
int main(int argc, char* argc){
string imageName("../image.png");
if (argc > 1) {
imageName = myClass::myClass();
temp.initialize(current_frame);
.
.
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;
}
}
myClass.cppModifier.cpp
myClass::myClass(){
//initialization of myClass object
}
void myClas::initialize(Mat frame){
vidSize = frame.size();
current = createContinous(vidSize, CV_8UC3);
current_gray = createContinous(vidSize, CV_8UC1);
current.upload(frame);
//unrelated parts
}
#include <opencv2\core\core.hpp>
#include <opencv2\highgui.hpp>
#include <opencv\imgcodecs.hpp>
#include <opencv2\imgproc\imgproc.hpp>
#include "Modifier.h"
using namespace cv;
Modify::Modify(Mat img){
this->image.upload(img);
}
GpuMat Modify::getImage(){
return this->image;
}
Modifier.h
#include <opencv2\core\core.hpp>
#include <opencv2\highgui.hpp>
#include <opencv\imgcodecs.hpp>
#include <opencv2\imgproc\imgproc.hpp>
using namespace cv;
using namespace cv::cuda;
class Modify
{
public:
Modify(Mat img);
GpuMat getImage();
protected:
GpuMat image;
since it is unable to read the frame's values cannot assign values to parameters. hope it helps.