Skip to content

[GSOC] ImageCollection Class improvements#27496

Draft
sturkmen72 wants to merge 80 commits intoopencv:4.xfrom
sturkmen72:ImageCollection
Draft

[GSOC] ImageCollection Class improvements#27496
sturkmen72 wants to merge 80 commits intoopencv:4.xfrom
sturkmen72:ImageCollection

Conversation

@sturkmen72
Copy link
Copy Markdown
Contributor

@sturkmen72 sturkmen72 commented Jun 30, 2025

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 another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the 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

TO DO:

  • complete the documentation of class members

@sturkmen72 sturkmen72 force-pushed the ImageCollection branch 2 times, most recently from 4c520ec to 807788b Compare June 30, 2025 22:36
@sturkmen72
Copy link
Copy Markdown
Contributor Author

@asmorkalov could you take a look at this PR. it is not urgent but maybe merging it before 4.12 release will be useful

@asmorkalov asmorkalov added this to the 4.12.0 milestone Jul 2, 2025
@asmorkalov asmorkalov self-requested a review July 2, 2025 07:58
@asmorkalov asmorkalov self-assigned this Jul 2, 2025
@sturkmen72 sturkmen72 changed the title [WIP] ImageCollection ImageCollection Class improvements Jul 2, 2025
@sturkmen72
Copy link
Copy Markdown
Contributor Author

@asmorkalov sorry to bother. there is a last minute fix for an issue.

CV_WRAP ImageCollection();
CV_WRAP ImageCollection(const String& filename, int flags = IMREAD_UNCHANGED);
CV_WRAP void init(const String& img, int flags);
CV_WRAP size_t size() const;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

size_t is not wrapped to Python and Java correctly. Java even does not support unsigned types. Please use int instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

size_t is not wrapped to Python and Java correctly. Java even does not support unsigned types. Please use int instead.

please check the last commit. i created size32() for wrapping

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i reverted size32()
CV_WRAP size_t size() const; seems working as python and java tests passed. also there is CV_EXPORTS_W size_t imcount(const String& filename, int flags = IMREAD_ANYCOLOR); what is your opinion.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it is unlikely we ever get an animation with INT_MAX frames anyway. Using an int is enough.

@sturkmen72
Copy link
Copy Markdown
Contributor Author

@asmorkalov OK, i have more time to better improvements.

@sturkmen72 sturkmen72 changed the title ImageCollection Class improvements [GSOC WIP] ImageCollection Class improvements Jul 2, 2025
@sturkmen72
Copy link
Copy Markdown
Contributor Author

✅ DECODER_OK = 0
Meaning:
The decoder has successfully completed its operation (e.g., reading the header or data). Everything is working as expected.

In ImageCollection:
The image is properly loaded and ready to be used (e.g., displayed, processed, or added to a collection).

⚠️ DECODER_UNINITIALIZED = 1
Meaning:
The decoder object was not properly initialized before use.
This often means some required setup (e.g., calling init() or setting a source) was skipped.

In ImageCollection:
This might occur if an image entry is added before setting a path, or if the decoder instance was used too early.

❌ DECODER_SOURCE_NOT_OPENED = 2
Meaning:
The decoder couldn’t open the source, such as a file path, memory buffer, or stream.

In ImageCollection:
This happens if:

The file doesn’t exist.

It’s unreadable (permissions issue).

It’s empty or corrupted.

The image will likely be skipped or flagged as a loading error.

❓ DECODER_UNKNOWN_SOURCE_FORMAT = 3
Meaning:
The source was opened, but the image format couldn’t be recognized or is unsupported.

In ImageCollection:
Examples:

A file with a .jpg extension that is actually a text file.

A valid file of a format not supported by the decoder (e.g., .tiff in a system that only supports PNG and JPEG).

🧱 DECODER_READ_HEADER_FAILED = 4
Meaning:
An error occurred while parsing the image header. This part usually contains size, color type, number of channels, etc.

In ImageCollection:

Indicates the image file is partially damaged or incorrectly encoded.

Common in corrupt downloads or truncated files.

💥 DECODER_READ_DATA_FAILED = 5
Meaning:
The image header was okay, but the decoder failed to read the actual image data (pixels, animation frames, etc.).

In ImageCollection:

Could occur during multi-frame extraction (e.g., animated WebP, GIF).

Or due to allocation issues (e.g., insufficient memory).

The image might show up with correct metadata but no pixel content.

@sturkmen72
Copy link
Copy Markdown
Contributor Author

another option is ( maybe simple is better )

class CV_EXPORTS_W ImageCollection {
public:
enum Status
{
    OK = 0,                      ///< No error.
    UNINITIALIZED = 1,           ///< The object has not been properly initialized.
    SOURCE_ERROR = 2,            ///< Failed to open or recognize the input source.
    READ_ERROR = 3               ///< Failed to read header or image data.
};

ImageCollection::Status::OK
ImageCollection::Status::UNINITIALIZED
ImageCollection::Status::SOURCE_ERROR
ImageCollection::Status::READ_ERROR

asmorkalov pushed a commit that referenced this pull request Aug 7, 2025
Performance tests for writing and reading animations #27605

### Pull Request Readiness Checklist

related : #27496

See details at https://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
- [ ] There is a reference to the 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
D00E pushed a commit to D00E/opencv that referenced this pull request Sep 19, 2025
Performance tests for writing and reading animations opencv#27605

### Pull Request Readiness Checklist

related : opencv#27496

See details at https://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
- [ ] There is a reference to the 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
@asmorkalov asmorkalov modified the milestones: 4.13.0, 4.14.0 Dec 9, 2025
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.

4 participants