I learned basic about C and C++ but my programming skills are bad. I am going to read some codes about image processing and I need to understand functions like this one below?
http://read.pudn.com/downloads6/sourcecode/multimedia/21391/MotionStabilization/ImageProcess.cpp__.htm
I am confused about two parameters, CImage *pImgSrc and CImage *pImgDst.
I think they are class pointers and the function is passed by reference.
Could you suggest what should I learn to understand this function and its parameters?
How should I use this function? If possible please tell me how to use the function with two parameters CImage *pImgSrc and CImage *pImgDst. Thank you.
Yes, they are class pointers, but what do you mean by "the function is passed by reference"? The function isn't being passed anywhere in the prototype.
If you read the comment above the function, there is some documentation about what it does (assuming you understand the purpose of the library, as I have no idea what an affine transform is) as well as descriptions of what most of the parameters are for.
Thanks. I am confused by function using class pointers as parameters and function which parameters are passed by reference.
For example, if I declare two variables as follows, which one is correct to use that function?
1 2 3
CImage a, b;
Trans_Geo_Affine(a, b,...)
Trans_Geo_Affine(&a, &b,...)
Remember that the & operator here is taking the address of the object it is applied to. Therefore:
In line 2, you are passing two CImage objects.
In line 3, you are passing two addresses of CImage objects.
Look again at the prototype for the function and you should be able to determine which the function is looking for. Does it want actual objects or addresses?
@ OP: Pointers have to point to something. For them to point to a valid object they would need to have been initialized like this for example:
CImage* a = new CImage, * b = new CImage;
Otherwise they hold whatever information is representative of the residual charge left over in that area of the RAM module from the last time it was used.
Now there are times when the documentation for some (likely) C based API tells you to pass a pointer into a function and that this pointer will receive the address of whatever variable and so you don't actually have to allocate the memory your self. If that is the case then you should still initialize them, but instead of a dynamic object you would point them to NULL:
You can determine this yourself by looking at the function prototype. Note that a and b are both of type CImage*, so do you want to pass a and b or &a and &b?