Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork56.4k
Fix bug with int64 support for FileStorage#26846
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Fix bug with int64 support for FileStorage#26846
Conversation
dfad11a to56ddb98Comparedkurt commentedJan 27, 2025
Probably, this fix may break compatibility on reading raw data serialized before with 4 bytes per int, doesn't it? |
dkurt commentedJan 27, 2025
@MaximSmolskiy, May I also ask you to open a PR with similar patch to 5.x branch? In such way we will test CV_64S Mat read/write too:https://github.com/opencv/opencv/pull/26399/files#diff-cf43289d2308f02754d618a5d975c44123ebb553fe074ccff700c7328a49badfR2078 |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
MaximSmolskiy commentedJan 27, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Yes, it is. But I can't think of any example code to do that. Can you please provide one? |
MaximSmolskiy commentedJan 27, 2025
|
dkurt commentedJan 28, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Never mind, I just checked that both 5.x and PR produces the same base64 raw data outputs for int32. Thanks for the patch! @staticmethoddefget_normal_2d_mat():rows=10cols=20cn=3image=np.zeros((rows,cols,cn),np.int32)image[:]= (1,2,127)foriinrange(rows):forjinrange(cols):image[i,j,1]= (i+j)%256returnimagedefwrite_base64_json(self,fname):fname="/home/d.kurtaev/test_file.json"fs=cv.FileStorage(fname,cv.FileStorage_WRITE_BASE64)mats= {'normal_2d_mat':self.get_normal_2d_mat()}forname,matinmats.items():fs.write(name,mat)fs.release() However seems like we should fix int64 base64 write mode later (in a separate PR for sure): diff --git a/modules/python/test/test_filestorage_io.py b/modules/python/test/test_filestorage_io.pyindex 01e0a72300..5ef0fd26ee 100644--- a/modules/python/test/test_filestorage_io.py+++ b/modules/python/test/test_filestorage_io.py@@ -124,7 +124,7 @@ class filestorage_io_test(NewOpenCVTests): cols = 20 cn = 3- image = np.zeros((rows, cols, cn), np.uint8)+ image = np.zeros((rows, cols, cn), np.int64) image[:] = (1, 2, 127) for i in range(rows): |
08a24ba intoopencv:4.xUh oh!
There was an error while loading.Please reload this page.
…test_base64-for-64-bit-integer-typesSupport 64-bit integer types for FileStorage Base64#26871### Pull Request Readiness ChecklistRelated to#26846 (comment)OpenCV extra:opencv/opencv_extra#1232See details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request- [x] I agree to contribute to the project under Apache 2 License.- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV- [x] The PR is proposed to the proper branch- [x] There is a reference to the original bug report and related work- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name.- [x] The feature is well documented and sample code can be built with the project CMake
…_support_for_FileStorageFix bug with int64 support for FileStorageopencv#26846### Pull Request Readiness ChecklistFixopencv#26829,opencv/opencv-python#1078In current implementation of `int64` support raw size of recorded integer is variable (`4` or `8` bytes depending on value). But then we iterate over nodes we need to know it exact valuehttps://github.com/opencv/opencv/blob/dfad11aae7ef3b3a0643379266bc363b1a9c3d40/modules/core/src/persistence.cpp#L2596-L2609Bug is that `rawSize` method still return `4` for any integer. I haven't figured out a way how to get variable raw size for integer in this method. I made raw size for integer is constant and equal to `8`.Yes, after this patch memory consumption for integers will increase, but I don't know a better way to do it yet. At least this fixes bug and implementation becomes more correctSee details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request- [x] I agree to contribute to the project under Apache 2 License.- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV- [x] The PR is proposed to the proper branch- [x] There is a reference to the original bug report and related work- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name.- [x] The feature is well documented and sample code can be built with the project CMake
Uh oh!
There was an error while loading.Please reload this page.
Pull Request Readiness Checklist
Fix#26829,opencv/opencv-python#1078
In current implementation of
int64support raw size of recorded integer is variable (4or8bytes depending on value). But then we iterate over nodes we need to know it exact valueopencv/modules/core/src/persistence.cpp
Lines 2596 to 2609 indfad11a
Bug is that
rawSizemethod still return4for any integer. I haven't figured out a way how to get variable raw size for integer in this method. I made raw size for integer is constant and equal to8.Yes, after this patch memory consumption for integers will increase, but I don't know a better way to do it yet. At least this fixes bug and implementation becomes more correct
See details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.