Skip to content

getCacheDirectory binding for Python#19668

Merged
alalek merged 2 commits intoopencv:masterfrom
asmorkalov:as/filesystem_py
Mar 4, 2021
Merged

getCacheDirectory binding for Python#19668
alalek merged 2 commits intoopencv:masterfrom
asmorkalov:as/filesystem_py

Conversation

@asmorkalov
Copy link
Copy Markdown
Contributor

@asmorkalov asmorkalov commented Mar 3, 2021

Replaces #18931 and adds more test for imgcodecs interop.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

}
//! @}
}} // namespace
}} // namespace fs
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fs?

#if OPENCV_HAVE_FILESYSTEM_SUPPORT
return cv::utils::fs::getCacheDirectory("downloads", "OPENCV_DOWNLOADS_CACHE_DIR");
#else
CV_Error(Error::StsNotImplemented, "File system support was disabled during OpenCV build!");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was disabled during OpenCV build

"is disabled in this OpenCV build" ?

try:
self.assertTrue(os.path.exists(path))
self.assertTrue(os.path.isdir(path))
os.rmdir(path)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to remove any "external" directory in tests? We don't own this.

finally:
os.remove(test_file_name)

self.assertEqual(cv.norm(gold_image - read_from_file), 0)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gold_image - read_from_file

Use 2 args instead of subtraction (it doesn't work correct with overflows/underflows)

}

namespace fs {
CV_EXPORTS_AS(getCacheDirectory) cv::String getCacheDirectoryForDownloads();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we should rename that?

This would cause confusion between C++ and Python getCacheDirectory() functions.

@asmorkalov asmorkalov requested a review from alalek March 3, 2021 14:36
Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@alalek alalek merged commit 2e42926 into opencv:master Mar 4, 2021
@alalek alalek mentioned this pull request Apr 9, 2021
a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
* Add Python Bindings for getCacheDirectory function

* Added getCacheDirectory interop test with image codecs.

Co-authored-by: Sergey Slashchinin <sergei.slashchinin@xperience.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants