Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@thewoz
Copy link
Contributor

@thewoz thewoz commented Oct 16, 2023

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

Hello everyone,
I created this new version of the imread function and I think it can be very useful in several cases.
It is actually passed to it object on which you want to upload the image.
The advantages can be different like in case one needs to open several large images all the same in sequence.
one can use the same pointer and the system would not allocate memory each time

@dkurt
Copy link
Member

dkurt commented Oct 17, 2023

First, I was confused why there is a need to have imread with pre-allocated memory while VideoCapture can do something like that (for example, read a sequence of the same size frames from a disc). Then, I thought that it might be useful.

@thewoz
Copy link
Contributor Author

thewoz commented Oct 17, 2023

Hi @dkurt thank you very much
I like to improve the documentation but my English is really bad

@dkurt
Copy link
Member

dkurt commented Oct 17, 2023

@thewoz, you may refer to current imread by @ref imread(const String&, int) but add a note that img param can be pre-allocated and memory is reused if sizes match.

@dkurt dkurt added the pr: needs test New functionality requires minimal tests set label Oct 18, 2023
@thewoz
Copy link
Contributor Author

thewoz commented Oct 20, 2023

Hello everyone,
I have been trying to do what you have suggested to do.
About @opencv-alalek
On point (1) I tried to do it but you then give me error on conversion.
On point (2) I did not understand what you mean.
On point (3) I removed the return from the function.
About @dkurt
I added the test in C++ . This is my first time doing this and I am not sure if I did it right.
On adding the python test unfortunately I wouldn't really know where to put my hands.

@thewoz
Copy link
Contributor Author

thewoz commented Oct 20, 2023

I hope I understood what you meant

Copy link
Contributor

@opencv-alalek opencv-alalek left a comment

Choose a reason for hiding this comment

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

Need to add Python tests (modules/imgproc/misc/python/test/test_imread.py).
See https://github.com/opencv/opencv/blob/4.x/modules/dnn/misc/python/test/test_dnn.py as reference.

Run Python test from build directory:

OPENCV_PYTHON_DEBUG=1 OPENCV_PYTEST_FILTER=test_imread* ./setup_vars.sh python3 ${OPENCV_SRC_DIR}/modules/python/test/test.py -v --repo ${OPENCV_SRC_DIR}

@thewoz
Copy link
Contributor Author

thewoz commented Nov 7, 2023

I tried to write the test in python
I am not sure if it is correct as I do not normally program in python

@thewoz
Copy link
Contributor Author

thewoz commented Nov 9, 2023

It remains to check the python test and what name to give to the function.
So far I have not been able in the test to load the lena image using findFile()
Anyway, I changed two lines of code in the imread_ function.
I put a check so that in this new version of the imread function the memory is ever allocated.
In fact if that happened the example written in test would fail.

@asmorkalov asmorkalov added this to the 4.10.0 milestone Mar 29, 2024
@asmorkalov asmorkalov merged commit afb91b5 into opencv:4.x Mar 29, 2024
@asmorkalov asmorkalov removed RFC pr: needs test New functionality requires minimal tests set labels Mar 29, 2024
@asmorkalov asmorkalov mentioned this pull request Apr 1, 2024
klatism pushed a commit to klatism/opencv that referenced this pull request May 17, 2024
Add imread opencv#24415

### Pull Request Readiness Checklist

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.
- [x] The feature is well documented and sample code can be built with the project CMake

Hello everyone,
I created this new version of the imread function and I think it can be very useful in several cases.
It is actually passed to it object on which you want to upload the image.
The advantages can be different like in case one needs to open several large images all the same in sequence.
one can use the same pointer and the system would not allocate memory each time.
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