Random non-zero pixels in cv.CreateImage after tostring() call. (Bug #1486)
Description
The usually black images created with cv.CreateImage
gets corrupted after a tostring()
conversion: random white pixels appear and CountNonZero
returns >0.
After iteration, the CountNonZero
grows and grows.
I wrote a testcase to demonstrate this behavior. It would be nice if you could add it to the source tree.
All default python-bindings test cases are OK on my system.
I suspect this causes segmentation faults and memory corruptions in more complicated and iterated usages. I couldn't reproduce these segfaults in a test case, anyway it's quite obvious that if the image memory space gets corrupted, other parts of the memory may be damaged as well.
See attached file.
Associated revisions
adjust the header parser to support "public virtual" construction and make a tweak for multiple inheritance, fix potential memory problem with Python's IplImage.tostring() method (ticket #1486)
Merge pull request #1486 from nzjrs:cv2-logpolar
History
Updated by Vadim Pisarevsky about 13 years ago
thanks for the test, I added it to our test system.
It can be the potential problem in tostring(), because in some cases it just increments the reference counter. I modified it to always return a separate copy (SVN, r7209).
However, there is bug in the test too. cv.CreateImage is not assumed to initialize the image with zeros. You must explicitly will it with zeros if needed:
image = cv.CreateImage(self.size, cv.IPL_DEPTH_8U, 1)
cv.Set(image, cv.Scalar(0,0,0,0))
after inserting cv.Set() after each cv.CreateImage() all the tests pass
- Status changed from Open to Done
- (deleted custom field) set to fixed
Updated by Andrey Kamaev about 13 years ago
- Target version set to 2.4.0
- Description changed from The usually black images created with cv.CreateImage gets corrupted after a t... to The usually black images created with @cv.CreateImage@ gets corrupted after a... More