opencv icon indicating copy to clipboard operation
opencv copied to clipboard

add imread

Open thewoz opened this issue 1 year ago • 12 comments

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

thewoz avatar Oct 16 '23 15:10 thewoz

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.

dkurt avatar Oct 17 '23 11:10 dkurt

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

thewoz avatar Oct 17 '23 12:10 thewoz

@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 avatar Oct 17 '23 12:10 dkurt

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 avatar Oct 20 '23 12:10 thewoz

I hope I understood what you meant

thewoz avatar Oct 20 '23 12:10 thewoz

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 avatar Nov 07 '23 16:11 thewoz

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.

thewoz avatar Nov 09 '23 22:11 thewoz

Hello everyone, I wanted to know if there was anything I could do. I'm trying to make a point. I keep having problems with the findFile() function.

I have tried with: ../cv/shared/lena.png /cv/shared/lena.png cv/shared/lena.png

keeps giving me as error: "OpenCV samples: Can't find required data file: cv/shared/lena.png in function 'findFile'"

what can i do?

as for python's test what do you think?

thewoz avatar Nov 27 '23 09:11 thewoz

@thewoz, https://github.com/opencv/opencv/pull/24415/files#r1386723679

dkurt avatar Nov 27 '23 10:11 dkurt

OpenCV samples: Can't find required data file: cv/shared/lena.png in function 'findFile'

You should not use API for "samples" in "tests". Take a look on other tests.

opencv-alalek avatar Dec 07 '23 17:12 opencv-alalek

Hi, @opencv-alalek I made the change. was that what you meant?

thewoz avatar Jan 04 '24 10:01 thewoz

As discussed on team meeting, let's check Mat is contiguous.

dkurt avatar Feb 03 '24 07:02 dkurt