New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copy cv.QueryFrame() into freshly created image #423
Copy cv.QueryFrame() into freshly created image #423
Conversation
Due to every cv.QueryFrame() modifies the same memory area we have to use cv.CreateImage() and copy our cv.QueryFrame() into it. This should fix the issue sightmachine#96.
Instead of copying
So, I think rather than making copies in each utility, the copy should be made when the image is created. |
I am going to go ahead and merge this in. Thanks! |
Copy cv.QueryFrame() into freshly created image
@kscottz This doesn't solve the real problem. It's just a workaround to get VirtualCamera working. We should make a copy of bitmap image while creating new |
This seems right to me. Is cv.copy not doing a deep copy? My understanding is that not doing a deep copy from the video frame buffer is the problem right? |
cv.Copy makes deepcopy. but this problem is a big one. It happens with everything. As I have provided the example, simple Image loading with iplimage has this problem. So I was saying, if we make copy of the source while creating the |
oooooooooooooooh I think I see it. Basically we're not doing the deep copy when we take in an IplImage to the ImageClass constructor? Does this example get at the heart of the problem?
|
Yeah, you are correct. but this example isn't right. Here, since you're doing |
@kscottz I found another referencing problem.
But this works
So, when you once call |
This is how it is done in Camera.getImage() (Line 588): frame = cv.RetrieveFrame(self.capture)
newimg = cv.CreateImage(cv.GetSize(frame), cv.IPL_DEPTH_8U, 3)
cv.Copy(frame, newimg)
return Image(newimg, self) |
@jayrambhia First example is out of our domain. Calling getBitmap really should be a protected method. Second example is numpy caching, we're never going to catch that either. Reminds me of an old joke |
@kscottz so I tried returning copies of bitmap, cvmat, numpy, etc https://github.com/jayrambhia/SimpleCV/compare/Main;referncing_issues and I got so many broken tests.. https://gist.github.com/jayrambhia/5423271 . So I'm just going to leave this alone as of now. But we should totally make a copy of iplimage while creating a new |
Due to every cv.QueryFrame() modifies the same memory area we have
to use cv.CreateImage() and copy our cv.QueryFrame() into it. This
should fix the issue #96.