Commit Graph

498 Commits

Author SHA1 Message Date
Suleyman TURKMEN
63b9cbc2d0 Update imgcodecs.hpp 2024-07-10 15:24:37 +03:00
Sourav Kumar
e962395565
Update imgcodecs.hpp 2024-07-09 06:53:16 +05:30
Vincent Rabaud
dfbd18e9aa
Merge pull request #25864 from vrabaud:legacy
Make sure all the lines of a JPEG are read #25864

In case of corrupted JPEG, imread would still return a JPEG of the proper size (as indicated by the header) but with some uninitialized values. I do not have a short reproducer I can add as a test as this was found by our fuzzers.

### 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
2024-07-05 08:53:28 +03:00
zihaomu
934e6899f8
Merge pull request #25809 from zihaomu:imread_rgb_flag
imgcodecs: Add rgb flag for imread and imdecode #25809

Try to `imread` images by RGB to save R-B swapping costs.

## How to use it?
```
img_rgb = cv2.imread("PATH", IMREAD_COLOR_RGB) # OpenCV decode the image by RGB format.
```

## TODO
- [x] Fix the broken code
- [x] Add imread rgb test
- [x] Speed test of rgb mode.

## Performance test

| file name | IMREAD_COLOR  | IMREAD_COLOR_RGB |
| --------- | ------ | --------- |
| jpg01     | 284 ms | 277 ms    |
| jpg02     | 376 ms | 366 ms    |
| png01     | 62 ms  | 60 ms     |
| Png02     | 97 ms  | 94 ms     |

Test with [image_test.zip](https://github.com/user-attachments/files/15982949/image_test.zip)
```.cpp
string img_path = "/Users/mzh/work/data/image_test/png02.png";
int loop = 20;

TickMeter t;

double t0 = 10000;
for (int i = 0; i < loop; i++)
{
    t.reset();
    t.start();
    img_bgr = imread(img_path, IMREAD_COLOR);
    t.stop();

    if (t.getTimeMilli() < t0) t0 = t.getTimeMilli();
}

std::cout<<"bgr time = "<<t0<<std::endl;

t0 = 10000;
for (int i = 0; i < loop; i++)
{
    t.reset();
    t.start();
    img_rgb = imread(img_path, IMREAD_COLOR_RGB);
    t.stop();
    if (t.getTimeMilli() < t0) t0 = t.getTimeMilli();
}
std::cout<<"rgb time = "<<t0<<std::endl;
``` 
### 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.
- [ ] The feature is well documented and sample code can be built with the project CMake
2024-07-03 10:58:25 +03:00
Mikhail Khachayants
bbf65a166e Fix file descriptor leak in HDR decoder 2024-06-30 18:43:04 +03:00
Maksim Shabunin
b77c74b6fc imgproc: fixed imread with output image argument, minor refactoring, fixes in HDR 2024-06-04 19:52:22 +03:00
Kumataro
b6593517c4
Merge pull request #25647 from Kumataro:fix25646
imgcodecs: support IMWRITE_JPEG_LUMA/CHROMA_QUALITY with internal libjpeg-turbo #25647

Close #25646

- increase JPEG_LIB_VERSION for internal libjpeg-turbo from 62 to 70
- add log when using IMWRITE_JPEG_LUMA/CHROMA_QUALITY with JPEG_LIB_VERSION<70
- add document IMWRITE_JPEG_LUMA/CHROMA_QUALITY requests JPEG_LIB_VERSION >= 70

### 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
- [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
2024-05-27 17:33:43 +03:00
Suleyman TURKMEN
7d6b6161cc Update imgcodecs tests 2024-05-15 22:24:21 +03:00
Alexander Smorkalov
9fe5615f2f Got rid of deprecated convertFp16 in imgcodecs module. 2024-05-03 11:05:08 +03:00
Alexander Smorkalov
5b0843728e
Merge pull request #25453 from Kumataro:fix25452
imgcodecs: jpeg: refactoring for JpegEncoder
2024-04-22 16:38:00 +03:00
Alexander Smorkalov
3f8b56ec49
Merge pull request #25459 from Kumataro:investigate_tiff_test
imgcodecs: tiff: test: ASSERT_NO_THROW() for imwrite/imread
2024-04-22 09:55:14 +03:00
Kumataro
26798e1f7c imgcodecs: tiff: test: ASSERT_NO_THROW() for imwrite/imread 2024-04-19 19:20:05 +09:00
Vincent Rabaud
fc5eb101bf
Merge pull request #25447 from vrabaud:tiff
Remove unnecessary FIXIT section in grfmt_tiff.cpp #25447

No int64/uint64 is used in the code anymore.

grfmt_tiff.hpp includes the tiff.h header inside of the tiff_dummy_namespace declaration. One implication of this is that all namespaced declarations made in tiff.h become qualified with tiff_dummy_namespace::.

Because tiff.h includes standard library headers, the std namespace declarations are converted to tiff_dummy_namespace::std declarations.

Subsequently, grfmt_tiff.hpp declares using namespace tiff_dummy_namespace;.

This can lead to an ambiguity error during the resolution of the std namespace.

### 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
- [x] There is a reference to the original bug report and related work
2024-04-19 13:00:27 +03:00
Kumataro
fb194a4582 imgcodecs: jpeg: refactoring for JpegEncoder 2024-04-19 15:06:28 +09:00
Alexander Smorkalov
9813ea2b7a
Merge pull request #25306 from utibenkei:fix_build_of_dynamic_framework_for_visionos
fix build of dynamic framework for visionos
2024-04-10 16:50:38 +03:00
Alexander Smorkalov
2d864c3af9 Export TIFF compression options as API and git rid of tiff.h. 2024-04-03 14:30:11 +03:00
utibenkei
fdc7cb6dc1 fix build of dynamic framework for visionos 2024-04-01 22:19:47 +09:00
Kumataro
9c8606e0c0 imgcodecs: jpeg: fix condition to compare rgb and cmyk jpeg 2024-03-30 13:49:08 +09:00
Kumataro
912cf2a028
Merge pull request #25280 from Kumataro:fix25274
imgcodecs: jpeg: re-support to read CMYK Jpeg #25280

Close #25274 
OpenCV Extra: https://github.com/opencv/opencv_extra/pull/1163

### 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
- [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
2024-03-29 17:38:06 +03:00
thewoz
afb91b552e
Merge pull request #24415 from thewoz:imread
Add imread #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.
2024-03-29 10:51:19 +03:00
Alexander Smorkalov
7b9de94003
Merge pull request #25255 from Kumataro:refactor_imgcodec_tiff_add_imwrite_tiff
imgcodecs: tiff: to avoid using TIFFTAG_* directly for imwrite() params.
2024-03-29 10:44:34 +03:00
RoboSchmied
8f4dbdad0e Fix: 6 typos
Signed-off-by: Michael Seibt <github@roboschmie.de>
2024-03-26 02:32:54 +01:00
Kumataro
bbfded21ac imgcodecs: tiff: to avoid using TIFFTAG_* directly for imwrite() params.
Normaly, we sets IMWRITE_* flags for imwrite() params.
But imgcodecs expects to use some TIFFTAG_* directory.
This patch introduce IMWRITE_TIFF_ROWSPERSTRIP and
IMWRITE_TIFF_PREDICTOR instead of TIFFTAG_*.
2024-03-23 10:16:30 +09:00
Michael Klatis
52f3f5a3f6
libtiff upgrade to version 4.6.0 (#25096)
* libtiff upgrade to version 4.6.0

* fix tiffvers.h cmake generation

* temp: force build 3rd party deps from source

* remove libport.h and spintf.c

* cmake fixes

* don't use tiff_dummy_namespace on windows

* introduce numeric_types namespace alias

* include cstdint

* uint16_t is not a numeric_types type

* fix uint16 and uint32 type defs

* use standard c++ types

* remove unused files

* remove more unused files

* revert build 3rd party code from source

---------

Co-authored-by: Misha Klatis <misha.klatis@autodesk.com>
2024-03-22 04:08:16 +03:00
Maksim Shabunin
bf06e3d09f
Merge pull request #25042 from mshabunin:doc-upgrade
Documentation transition to fresh Doxygen #25042

* current Doxygen version is 1.10, but we will use 1.9.8 for now due to issue with snippets (https://github.com/doxygen/doxygen/pull/10584)
* Doxyfile adapted to new version
* MathJax updated to 3.x
* `@relates` instructions removed temporarily due to issue in Doxygen (to avoid warnings)
* refactored matx.hpp - extracted matx.inl.hpp
* opencv_contrib - https://github.com/opencv/opencv_contrib/pull/3638
2024-03-05 16:19:45 +03:00
Dan Rosser
e596680939 Update ios_conversions.mm
Define fix for Mac Catalyst iOS
2024-02-26 19:21:52 +11:00
Kumataro
f5928a5be9 imgcodecs: refix 23416 to use perf::MatType 2024-02-08 12:35:29 +09:00
Alexander Smorkalov
c9671da732 Do not release user-provided buffer, if decoder failed. 2024-01-27 13:33:39 +03:00
Alexander Smorkalov
48ba45f856
Merge pull request #24875 from tailsu:sd/jpeg-turbo-color-extensions
jpeg: use libjpeg-turbo built-in color conversions
2024-01-23 14:32:56 +03:00
Sean McBride
e64857c561
Merge pull request #23736 from seanm:c++11-simplifications
Removed all pre-C++11 code, workarounds, and branches #23736

This removes a bunch of pre-C++11 workrarounds that are no longer necessary as C++11 is now required.
It is a nice clean up and simplification.

* No longer unconditionally #include <array> in cvdef.h, include explicitly where needed
* Removed deprecated CV_NODISCARD, already unused in the codebase
* Removed some pre-C++11 workarounds, and simplified some backwards compat defines
* Removed CV_CXX_STD_ARRAY
* Removed CV_CXX_MOVE_SEMANTICS and CV_CXX_MOVE
* Removed all tests of CV_CXX11, now assume it's always true. This allowed removing a lot of dead code.
* Updated some documentation consequently.
* Removed all tests of CV_CXX11, now assume it's always true
* Fixed links.

---------

Co-authored-by: Maksim Shabunin <maksim.shabunin@gmail.com>
Co-authored-by: Alexander Smorkalov <alexander.smorkalov@xperience.ai>
2024-01-19 16:53:08 +03:00
Stefan Dragnev
dabc325cac jpeg: use libjpeg-turbo built-in color conversions 2024-01-17 11:21:25 +01:00
Kumataro
46b3a504cf imgcodecs: suppress warning at test_avif.cpp 2023-12-29 12:58:24 +09:00
Letu Ren
4546f40d8b Refine logic of parsing PNG version
Currently, if `PNG_FOUND`, cmake scripts will check include and parse
header while we can use `PNG_VERSION_STRING` conveniently. If
`BUILD_PNG`, parse version from `PNG_LIBPNG_VER_STRING` directly is more
convenient than parsing major, minor and patch and concatenate them.

The comment of png.h also supports this.
```
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
```
https://github.com/glennrp/libpng/blob/libpng16/png.h#L287

This patch also modifies `ocv_parse_header_version` macro to receive
another parameter to make it more general.

The reason why changing `PNG_VERSION` to `PNG_VERSION_STRING` is to be
consistent with cmake's FindPNG.

This patch removes `HAVE_LIBPNG_PNG_H` variable because `PNG_INCLUDE_DIR`
is where to find png.h, etc according to
https://cmake.org/cmake/help/latest/module/FindPNG.html.

This patch also removes `PNG_PNG_INCLUDE_DIR` variable which is an
advanced variable used in cmake's FindPNG and is not used in opencv.
2023-12-23 16:01:42 +08:00
Giles Payne
3d9cb5329c
Merge pull request #24136 from komakai:visionos_support
Add experimental support for Apple VisionOS platform #24136

### 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

This is dependent on cmake support for VisionOs which is currently in progress.
Creating PR now to test that there are no regressions in iOS and macOS builds
2023-12-20 15:35:10 +03:00
Alexander Smorkalov
70b87804cf SPNG integration warning fixes. 2023-12-20 13:09:21 +03:00
Marek Kochanczyk
e9e6b1e22c
Merge pull request #24405 from kochanczyk:4.x
Extend the signature of imdecodemulti() #24405

(Edited after addressing Reviewers' comments.)

Add an argument to `imdecodemulti()` to enable optional selection of pages of multi-page images.

Be default, all pages are decoded. If used, the additional argument may specify a continuous selection of pages to decode.


### Pull Request Readiness Checklist

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

- [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] I agree to contribute to the project under Apache 2 License.
- [X] The PR is proposed to the proper branch
- [ ] 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.
- [ ] The feature is well documented and sample code can be built with the project CMake
2023-10-30 11:58:08 +03:00
Vincent Rabaud
44c254c09d Make sure AVIF decoder is destroyed in case of failure 2023-10-24 10:09:40 +02:00
Vincent Rabaud
3c9c964630 Check the return value of avifDecoderSetIOMemory.
The API will soon be made no_discard.
2023-10-23 14:56:24 +02:00
Sean McBride
5fb3869775
Merge pull request #23109 from seanm:misc-warnings
* Fixed clang -Wnewline-eof warnings
* Fixed all trivial clang -Wextra-semi and -Wc++98-compat-extra-semi warnings
* Removed trailing semi from various macros
* Fixed various -Wunused-macros warnings
* Fixed some trivial -Wdocumentation warnings
* Fixed some -Wdocumentation-deprecated-sync warnings
* Fixed incorrect indentation
* Suppressed some clang warnings in 3rd party code
* Fixed QRCodeEncoder::Params documentation.

---------

Co-authored-by: Alexander Smorkalov <alexander.smorkalov@xperience.ai>
2023-10-06 13:33:21 +03:00
Maksim Shabunin
1bccc14e05
Merge pull request #24343 from mshabunin:fix-test-writes
Fix tests writing to current work dir #24343

Several tests were writing files in the current work directory and did not clean up after test. Moved all temporary files to the `/tmp` dir and added a cleanup code.
2023-10-03 16:34:25 +03:00
Kumataro
4b1a4bdb49 imgcodecs: fix libtiff homepage 2023-08-27 19:49:37 +09:00
Alexander Smorkalov
23f27d8dbe Use OpenCV logging instead of std::cerr. 2023-07-19 10:49:54 +03:00
Yusuke Kameda
87f8cdd699
doxygen: Fix ImwriteFlags documentation misalignment 2023-07-11 19:08:58 +09:00
Vincent Rabaud
2af6775c14
Merge pull request #23943 from vrabaud:avif_tsan
Fix checkSignature not thread safe for AVIF. #23943

A common decoder cannot be shared with checkSignature which is used like a static function (on a static ist of decoders).

### 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
- [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
2023-07-11 10:25:53 +03:00
Vincent Rabaud
472aad46a6
Merge pull request #23596 from vrabaud:libavif
Add AVIF support through libavif. #23596

This is to fix https://github.com/opencv/opencv/issues/19271
Extra: https://github.com/opencv/opencv_extra/pull/1069

### 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
- [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
2023-06-09 15:39:10 +03:00
Alexander Smorkalov
a4a9f56c8b
Merge pull request #23513 from komakai:fix_unrecognized_selector
Fix "unrecognized selector" issue in Objective-C/Swift bindings
2023-04-24 11:29:41 +03:00
Alexander Smorkalov
e4a29d93fe Merge remote-tracking branch 'origin/3.4' into merge-3.4 2023-04-21 10:55:04 +03:00
Giles Payne
cfa5a270d3 Refactor Mat Converters and Mat QuickLook functionality to avoid "unrecognized selector" error 2023-04-18 21:09:55 +09:00
Sean McBride
47bea69322
Merge pull request #23055 from seanm:sprintf2
* Replaced most remaining sprintf with snprintf
* Deprecated encodeFormat and introduced new method that takes the buffer length
* Also increased buffer size at call sites to be a little bigger, in case int is 64 bit
2023-04-18 09:22:59 +03:00
Kumataro
d2dbaa4cd1
Merge pull request #23433 from Kumataro:4.x-fix23416
imgcodecs: tiff: Support to encode for CV_32S with compression params

Fix https://github.com/opencv/opencv/issues/23416

### 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
- [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.
- [ ] The feature is well documented and sample code can be built with the project CMake
2023-04-11 10:50:47 +03:00