value=cvQueryFrame( capture );
when I change the value, the lastValue value also changes
No, it is not. The value pointer is rewritten as you like. This line of code cannot affect lastValue .
but since they are pointers, both have the same meaning
No, it doesnโt matter that they are pointers. Pointers are still objects in their own right.
However , cvQueryFrame returns a pointer to a buffer that you should not modify, or for free , as this is done for you:
Please note that the image captured by the device is highlighted / released by the capture function. There is no need to publish it explicitly.
Although the documentation is a bit unclear, it seems to me that the buffer is only valid until the next call to cvQueryFrame (which then reuses the allocated memory). Therefore, even if lastValue cannot and does not change, in any case, a new frame is still indicated.
To get around this, you can explicitly copy the object that lastValue points to:
lastValue = cvCloneImage(value);
Now you are probably taking responsibility for his release (but again, this is not entirely clear from my cursory glance at the documentation):
cvReleaseImage(&lastValue);