Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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?

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:

Main.cpp

.
.
Mat current_frame(numRows, numCols, CV_8UC3);
myClass temp  = myClass::myClass();
temp.initialize(current_frame);
.
.

myClass.cpp

void myClas::initialize(Mat frame){
   vidSize = frame.size();
   current = createContinous(vidSize, CV_8UC3);
   current_gray = createContinous(vidSize, CV_8UC1); 
   current.upload(frame);

   //unrelated parts

}

since it is unable to read the frame's values cannot assign values to parameters. hope it's help.

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:

Main.cpp

.
.
Mat current_frame(numRows, numCols, CV_8UC3);
myClass temp  = myClass::myClass();
temp.initialize(current_frame);
.
.

myClass.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

}

since it is unable to read the frame's values cannot assign values to parameters. hope it's help.

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:

Main.cpp

.
.
Mat current_frame(numRows, numCols, CV_8UC3);
myClass temp  = myClass::myClass();
temp.initialize(current_frame);
.
.

myClass.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

}

since it is unable to read the frame's values cannot assign values to parameters. hope it's help.it helps.

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.

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 <iostream>
#include <opencv2\core\core.hpp>
<opencv2\core.hpp>
#include <opencv2\highgui.hpp>
#include <opencv\imgcodecs.hpp>
#include <opencv2\imgproc\imgproc.hpp>

#include "Modifier.h"
<opencv2\imgproc.hpp>

#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 <opencv2\core\core.hpp>
<opencv2\core.hpp>
#include <opencv2\highgui.hpp>
#include <opencv\imgcodecs.hpp>
#include <opencv2\imgproc\imgproc.hpp>

#include "Modifier.h"
<opencv2\imgproc.hpp>

#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.hModifier.hpp

#include <opencv2\core\core.hpp>
<opencv2\core.hpp>
#include <opencv2\highgui.hpp>
#include <opencv\imgcodecs.hpp>
#include <opencv2\imgproc\imgproc.hpp>
<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.

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 <iostream>
#include <opencv2\core.hpp>
#include <opencv2\highgui.hpp>
#include <opencv\imgcodecs.hpp>
#include <opencv2\imgproc.hpp>

#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 <opencv2\core.hpp>
#include <opencv2\highgui.hpp>
#include <opencv\imgcodecs.hpp>
#include <opencv2\imgproc.hpp>

#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.