CARVIEW |
Select Language
HTTP/2 200
date: Sun, 27 Jul 2025 22:05:39 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-repository-download: git clone https://github.com/opencv/opencv.git
etag: W/"e47fc48d606939ac47f18e5b4873d365"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=QNK3payhHi20IuVWGiO6ZBdE7ONhO%2F1miO7hRF6%2BJ1PBRXpeQlnmxq7qUpTikUHsq3qEs%2B4VWTN%2FJLNQJgJPLunXDAhfvRWZ4nPKH9Fea1eVqccmtlEDHreBazqBBrCgE794nRsgWkFDBb2w4K3EGW9XC99g2z8TP0yFdqmKnRCM7VrYiW4CNeMQMfELbFDOT8lEkqShwuHwa0j0nEI02Y8vE4AGlgCvMirfHUkTKZMpttBGXxMJTpuJyaX5uKC6PSg5CLV%2F1JgULq483%2F9kdQ%3D%3D--InJrvtKo4CSn42B4--ZWJbKvl6kH5Jd73sTzl9ZQ%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.115939148.1753653938; Path=/; Domain=github.com; Expires=Mon, 27 Jul 2026 22:05:38 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Mon, 27 Jul 2026 22:05:38 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: 98AE:29054:834437:ACCB96:6886A2B2
Merge pull request #25809 from zihaomu:imread_rgb_flag · opencv/opencv@934e689 · GitHub
Copy file name to clipboardExpand all lines: modules/imgcodecs/include/opencv2/imgcodecs.hpp
Copy file name to clipboardExpand all lines: modules/imgcodecs/perf/perf_jpeg.cpp
Copy file name to clipboardExpand all lines: modules/imgcodecs/perf/perf_png.cpp
Copy file name to clipboardExpand all lines: modules/imgcodecs/src/grfmt_avif.cpp
Copy file name to clipboardExpand all lines: modules/imgcodecs/src/grfmt_base.cpp
Copy file name to clipboardExpand all lines: modules/imgcodecs/src/grfmt_base.hpp
Copy file name to clipboardExpand all lines: modules/imgcodecs/src/grfmt_bmp.cpp
Copy file name to clipboardExpand all lines: modules/imgcodecs/src/grfmt_exr.cpp
Copy file name to clipboardExpand all lines: modules/imgcodecs/src/grfmt_exr.hpp
Copy file name to clipboardExpand all lines: modules/imgcodecs/src/grfmt_gdal.cpp
Skip to content
Navigation Menu
{{ message }}
-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
Commit 934e689
authored
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 CMake1 parent a7fd944 commit 934e689Copy full SHA for 934e689
File tree
Expand file treeCollapse file tree
34 files changed
+408
-95
lines changedFilter options
- modules/imgcodecs
- include/opencv2
- perf
- src
- test
Expand file treeCollapse file tree
34 files changed
+408
-95
lines changedmodules/imgcodecs/include/opencv2/imgcodecs.hpp
Copy file name to clipboardExpand all lines: modules/imgcodecs/include/opencv2/imgcodecs.hpp+6-4Lines changed: 6 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
68 | 68 |
| |
69 | 69 |
| |
70 | 70 |
| |
71 |
| - | |
| 71 | + | |
| 72 | + | |
72 | 73 |
| |
73 | 74 |
| |
74 | 75 |
| |
| |||
78 | 79 |
| |
79 | 80 |
| |
80 | 81 |
| |
81 |
| - | |
| 82 | + | |
| 83 | + | |
82 | 84 |
| |
83 | 85 |
| |
84 | 86 |
| |
| |||
268 | 270 |
| |
269 | 271 |
| |
270 | 272 |
| |
271 |
| - | |
| 273 | + | |
272 | 274 |
| |
273 | 275 |
| |
274 | 276 |
| |
| |||
279 | 281 |
| |
280 | 282 |
| |
281 | 283 |
| |
282 |
| - | |
| 284 | + | |
283 | 285 |
| |
284 | 286 |
| |
285 | 287 |
| |
|
modules/imgcodecs/perf/perf_jpeg.cpp
Copy file name to clipboardExpand all lines: modules/imgcodecs/perf/perf_jpeg.cpp+17Lines changed: 17 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
27 | 27 |
| |
28 | 28 |
| |
29 | 29 |
| |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
30 | 47 |
| |
31 | 48 |
| |
32 | 49 |
| |
|
modules/imgcodecs/perf/perf_png.cpp
Copy file name to clipboardExpand all lines: modules/imgcodecs/perf/perf_png.cpp+17Lines changed: 17 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
30 | 30 |
| |
31 | 31 |
| |
32 | 32 |
| |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
33 | 50 |
| |
34 | 51 |
| |
35 | 52 |
| |
|
modules/imgcodecs/src/grfmt_avif.cpp
Copy file name to clipboardExpand all lines: modules/imgcodecs/src/grfmt_avif.cpp+6-3Lines changed: 6 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
33 | 33 |
| |
34 | 34 |
| |
35 | 35 |
| |
36 |
| - | |
| 36 | + | |
37 | 37 |
| |
38 | 38 |
| |
39 | 39 |
| |
| |||
53 | 53 |
| |
54 | 54 |
| |
55 | 55 |
| |
56 |
| - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
57 | 60 |
| |
58 | 61 |
| |
59 | 62 |
| |
| |||
227 | 230 |
| |
228 | 231 |
| |
229 | 232 |
| |
230 |
| - | |
| 233 | + | |
231 | 234 |
| |
232 | 235 |
| |
233 | 236 |
| |
|
modules/imgcodecs/src/grfmt_base.cpp
Copy file name to clipboardExpand all lines: modules/imgcodecs/src/grfmt_base.cpp+6Lines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
53 | 53 |
| |
54 | 54 |
| |
55 | 55 |
| |
| 56 | + | |
56 | 57 |
| |
57 | 58 |
| |
58 | 59 |
| |
| |||
94 | 95 |
| |
95 | 96 |
| |
96 | 97 |
| |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
97 | 103 |
| |
98 | 104 |
| |
99 | 105 |
| |
|
modules/imgcodecs/src/grfmt_base.hpp
Copy file name to clipboardExpand all lines: modules/imgcodecs/src/grfmt_base.hpp+3Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
73 | 73 |
| |
74 | 74 |
| |
75 | 75 |
| |
| 76 | + | |
| 77 | + | |
76 | 78 |
| |
77 | 79 |
| |
78 | 80 |
| |
| |||
89 | 91 |
| |
90 | 92 |
| |
91 | 93 |
| |
| 94 | + | |
92 | 95 |
| |
93 | 96 |
| |
94 | 97 |
| |
|
modules/imgcodecs/src/grfmt_bmp.cpp
Copy file name to clipboardExpand all lines: modules/imgcodecs/src/grfmt_bmp.cpp+5Lines changed: 5 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
544 | 544 |
| |
545 | 545 |
| |
546 | 546 |
| |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
547 | 552 |
| |
548 | 553 |
| |
549 | 554 |
| |
|
modules/imgcodecs/src/grfmt_exr.cpp
Copy file name to clipboardExpand all lines: modules/imgcodecs/src/grfmt_exr.cpp+89-14Lines changed: 89 additions & 14 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
373 | 373 |
| |
374 | 374 |
| |
375 | 375 |
| |
376 |
| - | |
377 |
| - | |
378 |
| - | |
379 |
| - | |
380 |
| - | |
381 |
| - | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
382 | 394 |
| |
383 | 395 |
| |
384 | 396 |
| |
385 | 397 |
| |
386 | 398 |
| |
387 |
| - | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
388 | 405 |
| |
389 | 406 |
| |
390 | 407 |
| |
| |||
406 | 423 |
| |
407 | 424 |
| |
408 | 425 |
| |
409 |
| - | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
410 | 432 |
| |
411 | 433 |
| |
412 | 434 |
| |
| |||
430 | 452 |
| |
431 | 453 |
| |
432 | 454 |
| |
433 |
| - | |
434 |
| - | |
435 |
| - | |
436 |
| - | |
437 |
| - | |
438 |
| - | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
439 | 473 |
| |
440 | 474 |
| |
441 | 475 |
| |
| |||
558 | 592 |
| |
559 | 593 |
| |
560 | 594 |
| |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
561 | 636 |
| |
562 | 637 |
| |
563 | 638 |
| |
|
modules/imgcodecs/src/grfmt_exr.hpp
Copy file name to clipboardExpand all lines: modules/imgcodecs/src/grfmt_exr.hpp+1Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
83 | 83 |
| |
84 | 84 |
| |
85 | 85 |
| |
| 86 | + | |
86 | 87 |
| |
87 | 88 |
| |
88 | 89 |
| |
|
modules/imgcodecs/src/grfmt_gdal.cpp
Copy file name to clipboardExpand all lines: modules/imgcodecs/src/grfmt_gdal.cpp+2-2Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
397 | 397 |
| |
398 | 398 |
| |
399 | 399 |
| |
400 |
| - | |
| 400 | + | |
401 | 401 |
| |
402 | 402 |
| |
403 | 403 |
| |
404 | 404 |
| |
405 | 405 |
| |
406 |
| - | |
| 406 | + | |
407 | 407 |
| |
408 | 408 |
| |
409 | 409 |
| |
|
You can’t perform that action at this time.
0 commit comments