Answer the question
In order to leave comments, you need to log in
How to correctly work with pointers in c++?
I am working with the OpenCV 2 version library.
With it, I get a pointer to the image:
IplImage *frame; //я же правильно понимаю, это указатель?
int width = frame->width;
int height = frame->height;
class opencv
{
private: IplImage *frame, *gray;
public: void getGray() {
this->gray = cvCreateImage(cvSize(this->frame->width, this->frame->height), this->frame->depth, 1);
cvConvertImage(this->frame, this->gray, CV_BGR2GRAY);
}
}
public: IplImage * getGray() {
IplImage *gray = cvCreateImage(cvSize(this->frame->width, this->frame->height), this->frame->depth, 1);
cvConvertImage(this->frame, gray, CV_BGR2GRAY);
return gray;
}
Answer the question
In order to leave comments, you need to log in
To be honest, I didn't quite understand the question. so I will answer as I understand.
Creating a pointer is no different from creating another variable. This is just a variable that contains the value (4 bytes on x86, 8 bytes on x64) of the address of some memory cell. If this process is accompanied by memory allocation for something, then the process certainly becomes longer. But this does not go to any comparison with the speed in other languages, for example, interpreted ones. Therefore, there should not be a special zapar.
I don't quite understand what the problem is. In choosing how to return values from a function?
And through this-> and through return the speed is the same. These are linear operators with O(1) complexity (like all assignments) and shouldn't be a concern either.
And, to be honest, I don’t understand at all why take on OpenCV, which is quite difficult for a beginner, if you don’t even understand what a pointer is?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question