1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-21 19:33:03 +04:00

Compare commits

...

682 Commits

Author SHA1 Message Date
Alexander Alekhin dc15187f1b release: OpenCV 3.4.12 2020-10-10 20:14:29 +00:00
Alexander Alekhin ae1a249a0a Merge pull request #18557 from alalek:cuda_cmake_fix_auto 2020-10-10 20:02:03 +00:00
Alexander Alekhin 171fbf879f cmake: fix typo in CUDA_GENERATION=Auto cache 2020-10-09 22:00:02 +00:00
Alexander Alekhin 8a1caa0d16 Merge pull request #18554 from alalek:issue_17945 2020-10-09 19:54:17 +00:00
Alexander Alekhin cdcf7e62f3 dnn(opencl): bypass unsupported fusion cases 2 2020-10-09 18:59:08 +00:00
Alexander Alekhin 083727b0a6 Merge pull request #18551 from alalek:issue_17964 2020-10-09 16:08:12 +00:00
Alexander Alekhin 718dd9f170 dnn(opencl): bypass unsupported fusion cases 2020-10-09 12:33:06 +00:00
Alexander Alekhin 6c218c7b0f Merge pull request #18545 from alalek:enable_tests_17953 2020-10-08 21:39:48 +00:00
Alexander Alekhin e87a0baa4b dnn(test): enable tests from issue 17953 2020-10-08 20:27:03 +00:00
Alexander Alekhin 8ee5f2ad89 Merge pull request #18534 from alalek:build_opencv_winpack_dldt_2021.1.0 2020-10-08 15:32:03 +00:00
Alexander Alekhin ee76cef1ff Merge pull request #18527 from alalek:dnn_test_openvino 2020-10-08 15:27:50 +00:00
Alexander Alekhin 6da05f7086 dnn(test): update tests for OpenVINO 2021.1 2020-10-08 10:22:31 +00:00
Alexander Alekhin e24b1629a0 Merge pull request #18536 from alalek:backport_doxygen_style_18195 2020-10-07 21:35:58 +00:00
Alexander Alekhin d9ea9bedb2 doxygen: backport style changes 2020-10-07 20:16:40 +00:00
Alexander Alekhin 1546b9bf99 build: winpack_dldt with dldt 2021.1.0 2020-10-07 16:16:53 +00:00
Alexander Alekhin 62b5d37b6b Merge pull request #18526 from alalek:fix_uninitialized_warnings 2020-10-06 22:49:55 +00:00
Alexander Alekhin d78d9bf151 Merge pull request #18519 from alalek:fix_javadoc 2020-10-06 22:48:21 +00:00
Alexander Alekhin a5f0fb6008 Merge pull request #18518 from alalek:backport_17993 2020-10-06 22:47:45 +00:00
Alexander Alekhin f2bb3d0d80 videoio(dc1394_v2): ensure variable initialization 2020-10-06 21:00:36 +00:00
Alexander Alekhin 037a72debd Merge pull request #18517 from alalek:backport_18031 2020-10-06 19:56:49 +00:00
Alexander Alekhin 1ef4b7ae5a Merge pull request #18515 from alalek:test_18473 2020-10-06 19:39:28 +00:00
Alexander Alekhin b314cc4c23 Merge pull request #18506 from alalek:issue_18472 2020-10-06 19:37:40 +00:00
Alexander Alekhin 644de8f22a java: fix javadoc generation 2020-10-06 04:28:25 +00:00
Maksim Doronin 36f61f3879 [IE][VPU]: Refactor vpu configs
backported commit: 7fe87d9a5b
2020-10-05 20:27:52 +00:00
Ilya Churaev aa11f7d8a3 Removed get_output_as_single_output_node method
backported commit: 5fd3d36fe8
2020-10-05 20:24:21 +00:00
Alexander Alekhin f30aafc3cc core(test): regression test for 18473 2020-10-05 17:14:22 +00:00
Alexander Alekhin 2f065b8b4c Merge pull request #18509 from alalek:issue_18392 2020-10-05 17:03:27 +00:00
Alexander Alekhin aece3e732e Merge pull request #18507 from sizeofvoid:openbsd 2020-10-05 17:02:38 +00:00
Alexander Alekhin ebe9327a92 Merge pull request #18473 from BioDataAnalysis:bda_fix_cv_mat_steps 2020-10-05 16:59:05 +00:00
Mario Emmenlauer 102d8f67cd matrix.cpp::setSize(): fixed out-of-bounds access on cv::Mat steps 2020-10-05 10:19:53 +02:00
Alexander Alekhin a00fe15abd dnn: check for empty Net in .forward() 2020-10-05 06:23:47 +00:00
Rafael Sadowski 3acf8cfd63 Add an OpenBSD check 2020-10-05 08:23:23 +02:00
Alexander Alekhin d34717d8c9 core: allow to disable including of unsupported/Eigen/CXX11/Tensor
- define OPENCV_DISABLE_EIGEN_TENSOR_SUPPORT
2020-10-04 15:14:46 +00:00
Alexander Alekhin a5b8f163d7 Merge pull request #18488 from alalek:maxflow_missing_check 2020-10-02 15:04:28 +00:00
Alexander Alekhin 6add3b9161 Merge pull request #18487 from aitikgupta:unnecessary-variable 2020-10-02 15:03:59 +00:00
Alexander Alekhin 1ddd61f98a Merge pull request #18458 from sturkmen72:Update_window_w32_cpp 2020-10-02 15:00:44 +00:00
Alexander Alekhin 3503a36e5e Merge pull request #18444 from aitikgupta:check-minimum-points 2020-10-02 14:59:07 +00:00
Alexander Alekhin 2ea7269450 Merge pull request #18431 from zhuqiang00099:fix-darknet_relu 2020-10-02 14:58:48 +00:00
zhuqiang00099 a968eadbf1 fix darknet-relu bug in darknet_io.cpp 2020-10-02 06:16:38 +00:00
Alexander Alekhin c6b63e0e28 calib3d/imgproc: add GCGraph::maxFlow() missing empty checks 2020-10-02 05:15:20 +00:00
Aitik Gupta 7bd8ddc8fa removed no-affect variable 2020-10-02 09:27:16 +05:30
Suleyman TURKMEN 14e264f646 Update window_w32.cpp 2020-09-29 21:50:06 +03:00
Alexander Alekhin 969b55036f Merge pull request #18438 from alalek:dnn_onnx_importer_error_reporting 2020-09-29 13:49:02 +00:00
Aitik Gupta cbf978d1f7 added minPoints Homography test 2020-09-29 01:04:15 +05:30
Aitik Gupta 94e0ac7d9f need atleast 4 corresponding points to calculate homography 2020-09-29 01:04:01 +05:30
Alexander Alekhin 08b36e4f48 Merge pull request #18449 from alalek:ios_dont_disable_world_automatically 2020-09-28 18:46:28 +00:00
Alexander Alekhin d62d880316 Merge pull request #18447 from alalek:fix_17953 2020-09-28 18:45:31 +00:00
Alexander Alekhin 361b5e0ebf Merge pull request #18430 from alalek:ippicv_tpp 2020-09-28 18:45:00 +00:00
Alexander Alekhin c16e2e6234 ios: don't force BUILD_opencv_world=OFF in case of excluded modules 2020-09-28 01:11:15 +00:00
Alexander Alekhin c08f29c803 dnn(opencl): fix convolution kernel w/o bias with activation 2020-09-27 23:42:30 +00:00
Alexander Alekhin ecb6d03ccd Merge pull request #18445 from alalek:fix_test_python_ml 2020-09-27 23:12:02 +00:00
Alexander Alekhin e59793cc75 dnn: improve debugging of ONNX parsing errors 2020-09-27 23:04:48 +00:00
Alexander Alekhin 236ad4aeda Merge pull request #18441 from alalek:core_check_force_string_literals 2020-09-27 23:03:18 +00:00
Alexander Alekhin 97bb91d5fa ml: fix python test 2020-09-27 21:14:55 +00:00
Alexander Alekhin 233030e417 core: force check for string literals are used in the message 2020-09-27 06:37:44 +00:00
Alexander Alekhin 6256e425f3 Merge pull request #18434 from tomoaki0705:loosenDNNEps 2020-09-26 21:08:13 +00:00
Tomoaki Teshima 48368dc9a1 loosen threshold for Mali 2020-09-27 00:37:52 +09:00
Alexander Alekhin 691c655630 ippicv: install third-party-programs.txt file 2020-09-25 22:09:25 +00:00
Alexander Alekhin b88ad7f2d9 Merge pull request #18427 from tomoaki0705:improveFlipTest 2020-09-25 19:49:26 +00:00
Alexander Alekhin b300b6b3bd Merge pull request #18424 from tomoaki0705:addRTX3080s 2020-09-25 19:48:04 +00:00
Tomoaki Teshima 234117800f brush up by following the comments 2020-09-25 23:57:15 +09:00
Tomoaki Teshima ac58b2f857 compute capability 8.6
- CC for RTX3090, RTX3080 and RTX3070
2020-09-25 22:33:55 +09:00
Alexander Alekhin 220b37144b Merge pull request #18395 from tomoaki0705:fixNativePow 2020-09-23 18:27:45 +00:00
Tomoaki Teshima 74c8ccb45b fix build error of kernel on Mali 2020-09-23 21:38:12 +09:00
Alexander Alekhin 9cfe981e1f Merge pull request #18378 from nathanrgodwin:ippe_fix 2020-09-23 09:13:49 +00:00
Nathan Godwin 2f9072efdc Fixed assertions on ippe solver 2020-09-21 21:56:28 -05:00
Alexander Alekhin 5e90802b1a Merge pull request #18363 from alalek:issue_18349 2020-09-19 16:53:34 +00:00
Alexander Alekhin 45fee13f3d Merge pull request #18362 from alalek:ocl_async_kernel_reschedule_bug 2020-09-19 16:53:16 +00:00
Alexander Alekhin 261ad78122 core: emit more clear messages in OutputArray::create() 2020-09-18 15:25:29 +00:00
Alexander Alekhin 4fa82809df ocl: avoid rescheduling of async kernels 2020-09-18 14:53:50 +00:00
Alexander Alekhin 3e3787ecb6 Merge pull request #18360 from tomoaki0705:fixClampFailure 2020-09-18 13:10:36 +00:00
Alexander Alekhin a723aaedd8 Merge pull request #18354 from takehirokj:fix_typo_in_doc 2020-09-18 13:10:10 +00:00
Liubov Batanina ebb528976f Merge pull request #18353 from l-bat:issue_18350
* Fixed bug in ONNX Mul op

* Replaced node
2020-09-18 13:01:14 +00:00
Tomoaki Teshima f77c2d700f add explicit cast for half 2020-09-18 21:04:24 +09:00
Takehiro Kajihara 8c44b8306b Fix typo in videoio doc 2020-09-18 07:34:10 +09:00
Alexander Alekhin e668cff573 Merge pull request #18348 from tomoaki0705:fixNppFlipInplace 2020-09-17 13:56:17 +00:00
Sergei Slashchinin fa953e4205 Merge pull request #18316 from sl-sergei:fix_18253
Fix loading of ONNX models with Resize operation with Opset 11 for newer versions of Pytorch

* Add reproducer for Resize operation from newer versions of Pytorch

* Fix loading of scales parameter for Resize layer

* Change check type for better diagnostic messages
2020-09-17 11:05:22 +00:00
Maksim Shabunin 540982cc9d Merge pull request #18331 from or-toledano:3.4 2020-09-16 21:00:05 +00:00
Tomoaki Teshima a61546680b use only even number for inplace flip 2020-09-16 15:45:03 +09:00
Alexander Alekhin 8cb7eae5c9 Merge pull request #18294 from mshabunin:install-bin-samples 2020-09-15 19:38:02 +00:00
Alexander Alekhin 18440c1faf Merge pull request #18314 from gilsho:components 2020-09-14 20:15:38 +00:00
Alexander Alekhin 9f69ca503a Merge pull request #18325 from alalek:issue_18166 2020-09-14 18:17:58 +00:00
or-toledano 49ba744130 Fix np row,column to cv y,x
This explanation was created to avoid confusion, but it seems like the author was confused :D
2020-09-14 14:23:38 +03:00
Alexander Alekhin 4b24ddd70d Merge pull request #18317 from sl-sergei:restored_pr_17629 2020-09-13 12:51:41 +00:00
Gil Shotan 1612db5f91 Fix signed integer overflow in connected components 2020-09-13 11:20:42 +00:00
Alexander Alekhin 7dfe68cac6 imgcodecs: lazy on-demand codecs initialization 2020-09-13 11:14:56 +00:00
Alexander Alekhin 83807811cd Merge pull request #18299 from l-bat:onnx_reduce_max 2020-09-12 22:01:09 +00:00
Shubham Singh 23e71d1aa2 fixes #17187 probably
Added Eltwise Layer Support
2020-09-11 18:53:42 +03:00
Liubov Batanina b542a1804c Support global reduce ops 2020-09-09 11:56:20 +03:00
Maksim Shabunin 2dff2f36bf Install: added prebuilt samples installation 2020-09-08 20:22:26 +03:00
Alexander Alekhin 6b674709b8 Merge pull request #18284 from alalek:update_ffmpeg_3.4 2020-09-08 11:26:48 +00:00
Alexander Alekhin f56445d7ca ffmpeg/3.4: update FFmpeg wrapper
- FFmpeg 3.4.8
2020-09-07 17:55:22 +00:00
Alexander Alekhin 03bee14372 Merge pull request #18282 from alalek:update_version_3.4.12-pre 2020-09-07 16:57:21 +00:00
Alexander Alekhin 50ff40d684 pre: OpenCV 3.4.12 (version++) 2020-09-06 22:26:32 +00:00
Danny c31164bf1e Merge pull request #18126 from danielenricocahall:add-oob-error-sample-weighting
Account for sample weights in calculating OOB Error

* account for sample weights in oob error calculation

* redefine oob error functions

* fix ABI compatibility
2020-09-05 18:52:10 +00:00
Alexander Alekhin 3835ab394e Merge pull request #18265 from alalek:fixup_17489 2020-09-04 17:02:08 +00:00
Danny 20b23da8e2 Merge pull request #18061 from danielenricocahall:fix-kd-tree
Fix KD Tree kNN Implementation

* Make KDTree mode in kNN functional

remove docs and revert change

Make KDTree mode in kNN functional

spacing

Make KDTree mode in kNN functional

fix window compilations warnings

Make KDTree mode in kNN functional

fix window compilations warnings

Make KDTree mode in kNN functional

casting

Make KDTree mode in kNN functional

formatting

Make KDTree mode in kNN functional

* test coding style
2020-09-04 17:01:05 +00:00
Alexander Alekhin f6795d75a6 videoio: repair build of FFmpeg windows wrapper 2020-09-04 15:36:10 +00:00
Alexander Alekhin fa11b98800 Merge pull request #18255 from alalek:backport_18243 2020-09-02 22:50:21 +00:00
Alexander Alekhin 64c67a93d3 Merge pull request #18246 from YashasSamaga:dnn-permute-fix-unwanted-ocl-init 2020-09-02 21:15:19 +00:00
Alexander Alekhin 154380ccf5 Merge pull request #18234 from l-bat:onnx_reshape 2020-09-02 19:31:22 +00:00
Alexander Alekhin 1f2c83845d backport: checks and fixes from static code analyzers results
original commit: 71f665bd8c
2020-09-02 19:05:47 +00:00
Liubov Batanina 2349a09736 Support Reshape with zero dim 2020-09-02 11:58:43 +03:00
YashasSamaga 1df533c914 fix typo in fusion tests 2020-09-02 14:25:36 +05:30
YashasSamaga 44bf748479 do not allocate UMat in non-OpenCL targets 2020-09-02 12:18:41 +05:30
Alexander Alekhin f9fbd29c14 Merge pull request #18225 from dmici:fix_missing_0.5_factor_in_anisotropic_segmentation_tutorial 2020-09-01 20:49:59 +00:00
pemmanuelviel 31dc3e9256 Merge pull request #18211 from pemmanuelviel:pev--handle-dna-vectors
* DNA-mode: update miniflann to handle DNA

* DNA-mode: update hierarchical kmeans to handle DNA sequences
2020-09-01 20:38:21 +00:00
Yosshi999 698b2bf729 Merge pull request #18167 from Yosshi999:bit-exact-gaussian
Bit exact gaussian blur for 16bit unsigned int

* bit-exact gaussian kernel for CV_16U

* SIMD optimization

* template GaussianBlurFixedPoint

* remove template specialization

* simd support for h3N121 uint16

* test for u16 gaussian blur

* remove unnecessary comments

* fix return type of raw()

* add typedef of native internal type in fixedpoint

* update return type of raw()
2020-09-01 10:28:25 +00:00
Alexander Alekhin 1d42560018 Merge pull request #18235 from alalek:ocl_off_cleanup 2020-08-31 20:37:41 +00:00
Alexander Alekhin efcf307b4c ocl: cleanup dead code in case of disabled OpenCL 2020-08-31 11:30:42 +00:00
dmici 6876f3b91d fix missing 0.5 factor in anisotropic segmentation tutorial 2020-08-30 10:17:50 +02:00
Yosshi999 7495a4722f Merge pull request #18053 from Yosshi999:bit-exact-resizeNN
Bit-exact Nearest Neighbor Resizing

* bit exact resizeNN

* change the value of method enum

* add bitexact-nn to ResizeExactTest

* test to compare with non-exact version

* add perf for bit-exact resizenn

* use cvFloor-equivalent

* 1/3 scaling is not stable for floating calculation

* stricter test

* bugfix: broken data in case of 6 or 12bytes elements

* bugfix: broken data in default pix_size

* stricter threshold

* use raw() for floor

* use double instead of int

* follow code reviews

* fewer cases in perf test

* center pixel convention
2020-08-28 21:20:05 +03:00
Alexander Alekhin 7ce56b3a47 Merge pull request #18207 from pemmanuelviel:pev--fix-memset 2020-08-27 17:10:23 +00:00
Pierre-Emmanuel Viel 5376863c0c bugfix 2020-08-27 12:21:02 +02:00
Alessandro de Oliveira Faria (A.K.A.CABELO) a86e036594 Merge pull request #18184 from cabelo:yolov4-in-model
ADD yolov4 in models.yml
2020-08-26 22:30:12 +00:00
Alexander Alekhin 01324b02e7 Merge pull request #18136 from nglee:dev_cudaEqualizeHistBitExact 2020-08-26 12:11:43 +00:00
Alexander Alekhin 792722865f Merge pull request #17919 from zhaoyue-zephyrus:flownet2_with_anysize 2020-08-26 11:43:17 +00:00
Sergei Slashchinin 9aa401a7d0 Merge pull request #17978 from sl-sergei:fix_17516_17531
* Fix ONNX loading in issues opencv#17516, opencv#17531

* Add tests for Linear and Matmul layers

* Disable tests for IE versions lower than 20.4

* Skip unstable tests with OpenCL FP16 on Intel GPU

* Add correct test filtering for OpenCL FP16 tests
2020-08-26 10:15:59 +00:00
jinyup100 a160e4fb6b Merge pull request #17647 from jinyup100:add-siamrpnpp
[GSoC] Add siamrpnpp.py

* Updated base branch with siamrpnpp.py

* Addition of Parsers

* Merged to using few ONNX files, Changes to Parsers, Links to Repo

* Deleted whitespace

* Adjusting flake8 error

* Fixes according to review

* Fix according to review

* Addition of OpenVINO backends and Computation target devices

* Fix on backend after review

* Fixes after review

* Remove extra white space

* Removed Repeated Varaibles
2020-08-25 20:01:16 +00:00
Alexander Alekhin c7422e4d90 Merge pull request #18171 from catree:fix_pnp_doc 2020-08-25 18:24:30 +00:00
Alexander Alekhin 485d2b593c Merge pull request #18178 from catree:improve_camera_matrix_doc 2020-08-25 13:33:39 +00:00
Alexander Alekhin 1bea537731 Merge pull request #18165 from catree:fix_hand_eye_calibration_Andreff_NaN_3.4 2020-08-25 13:28:21 +00:00
Alexander Alekhin 75e88d613f Merge pull request #18185 from VadimLevin:dev/vlevin/ffmpeg-versions-guard-fix 2020-08-25 07:29:42 +00:00
catree 379b83e946 Fix cubic root computation to be able to handle negative values. Improve doc. Add regression test. 2020-08-25 03:37:56 +02:00
catree dda1bf1887 Add broken implementation note for DLS and UPnP.
Add CV_LOG_DEBUG.
2020-08-25 03:07:00 +02:00
Vadim Levin f7e524cbe6 fix: libavcodec version check for AVDISCARD_NONINTRA
- AVDISCARD_NONINTRA flag is supported only for FFMPEG libraries pack
2020-08-24 23:12:49 +03:00
Vadim Levin e503ac508e fix: libavcodec version check for AV_CODEC_FLAG_GLOBAL_HEADER 2020-08-24 23:07:25 +03:00
Alexander Alekhin f5ba3f51ce Merge pull request #18181 from l-bat:onnx_pow 2020-08-24 14:18:08 +00:00
Liubov Batanina d392b11dfb Supported ONNX Pow op 2020-08-24 11:20:18 +03:00
catree cd01ee9a54 Use camera intrinsic matrix everywhere. Add cameramatrix, distcoeffs and distcoeffsfisheye macros to avoid copy/paste errors. 2020-08-24 05:39:23 +02:00
Ian Maquignaz 8c1af09989 Merge pull request #18083 from IanMaquignaz:fix_gen_pattern_centering
* Fixed centering issue with make_cicle_pattern and make_acircle_pattern()

* Fixed issue where asymmetric circles were not at 45 degree angles. Also fixed support for inch measurement by converting parsing to usage of floating points for page size

* Fixed copy-paste error from experimental workspace
2020-08-23 22:32:58 +00:00
Alexander Alekhin f53ff0d01c Merge pull request #18151 from alalek:core_trace_fix_location 2020-08-21 18:54:40 +00:00
Alexander Alekhin 4f48dab023 Merge pull request #18150 from alalek:ocl_async_cleanup_no_warning 2020-08-21 18:54:08 +00:00
Namgoo Lee a7ffcaab28 Remove compiler warnings 2020-08-21 23:52:30 +09:00
Namgoo Lee f617f18e46 bit-exact cuda::equalizeHist 2020-08-21 22:53:40 +09:00
Alexander Alekhin 4372d75b26 Merge pull request #18135 from AnnaPetrovicheva:logo_text 2020-08-21 13:07:26 +00:00
Anna Petrovicheva 885fb703cf Added a note about OpenCV logo 2020-08-21 11:18:40 +03:00
Alexander Alekhin cd00d8f3f0 core(trace): lazy quering for OPENCV_TRACE_LOCATION
- fixes proper initialization of non-trivial variable
2020-08-20 21:48:05 +00:00
Alexander Alekhin b3755e617c ocl: silence warning in case of async cleanup
- OpenCL kernel cleanup processing is asynchronous and can be called even after forced clFinish()
- buffers are released later in asynchronous mode
- silence these false positive cases for asynchronous cleanup
2020-08-20 19:33:37 +00:00
Alexander Alekhin fc0f9da7a7 Merge pull request #18084 from pemmanuelviel:pev--add-DNA-distances 2020-08-20 13:26:02 +00:00
Alexander Alekhin 277961fa25 Merge pull request #18085 from pemmanuelviel:pev--add-DbgAssert-checks 2020-08-20 13:25:02 +00:00
Alexander Alekhin 14a9103fc0 Merge pull request #18129 from pemmanuelviel:pev--update-stereo-sample 2020-08-20 13:21:58 +00:00
Pierre-Emmanuel Viel 6d1f7c2b1b Update the stereo sample:
* add the HH4 mode
* option to display disparity with a color map
* display current settings in the title bar
* don't close app when wanting to take screenshots
2020-08-20 12:20:25 +02:00
Alexander Alekhin 2c1f3487a4 Merge pull request #18037 from danielenricocahall:improve-brisk-init-perf 2020-08-18 20:06:17 +00:00
Alexander Alekhin acc6189da0 Merge pull request #18022 from SoheibKadi:Update_CornerSubPix_Documentation 2020-08-18 13:19:18 +00:00
danielenricocahall ac177b849c Improve initialization performance of Brisk
reformatting

Improve initialization performance of Brisk

fix formatting

Improve initialization performance of Brisk

formatting

Improve initialization performance of Brisk

make a lookup table for ring

use cosine/sine lookup table for theta in brisk and utilize trig identity

fix ring lookup table

use cosine/sine lookup table for theta in brisk and utilize trig identity

formatting

use cosine/sine lookup table for theta in brisk and utilize trig identity

move scale radius product to ring loop to ensure it's not recomputed for each rot

revert change

move scale radius product to ring loop to ensure it's not recomputed for each rot

remove rings lookup table

move scale radius product to ring loop to ensure it's not recomputed for each rot

fix formatting of for loop

move scale radius product to ring loop to ensure it's not recomputed for each rot

use sine/cosine approximations for brisk lookup table.

add documentation for sine/cosine lookup tables

Improve initialization performance of BRISK
2020-08-18 07:11:21 -04:00
Alexander Alekhin 29aeebf5bc Merge pull request #18119 from tomoaki0705:fixFfmpegBuildFailure 2020-08-17 19:25:55 +00:00
Tomoaki Teshima cc769ff19d fix build error on odroid-n2-plus 2020-08-17 21:24:54 +09:00
Yosshi999 1834eed809 Merge pull request #18001 from Yosshi999:sift-8bit-descr
* 8-bit SIFT descriptors

* use clearer parameter

* update docs

* propagate type info

* overload function for avoiding ABI-break

* bugfix: some values are undefined when CV_SIMD is absent
2020-08-17 10:28:44 +00:00
Alexander Alekhin b34234ac14 Merge pull request #18105 from alalek:highgui_gtk_dont_terminate 2020-08-17 08:52:01 +00:00
Alexander Alekhin 7ec9f52509 highgui: don't terminate if we can't initialize GTK backend
- allow Users to handle such case
- exception will be thrown instead
2020-08-16 09:30:09 +00:00
nhlsm 68f527267b Merge pull request #18080 from nhlsm:improve-mat-operator-assign-scalar
* improve Mat::operator=(Scalar)

* touch

* remove trailing whitespace

* TEST: check if old code pass test or not

* remove CV_Error

* remove warning

* fix: is -> Scalar

* 1) Mat *mat -> Mat &mat 2) return bool, add output param

* add comment
2020-08-14 17:21:23 +00:00
Alexander Alekhin 7f22b34c78 Merge pull request #18092 from alalek:ocl_fix_image_format 2020-08-14 17:10:36 +00:00
Liubov Batanina ad63d24dba Merge pull request #18096 from l-bat:update_onnx_importer
* Added ReduceSum to ONNX importer

* Fix comments

* Fix Mul
2020-08-14 16:49:42 +00:00
Alexander Alekhin 3b5813c035 Merge pull request #18078 from l-bat:fix_matmul 2020-08-14 13:46:46 +00:00
Liubov Batanina 339b963e6b Fix MatMul and Add axes 2020-08-14 11:18:58 +03:00
Alexander Alekhin 00890aecdf core(ocl): fix ocl::Image2d::isFormatSupported()
in case of OPENCV_OPENCL_DEVICE=disabled
2020-08-13 18:33:18 +00:00
Yashas Samaga B L 2171cae8ff Merge pull request #17976 from YashasSamaga:dnn-fusion-tests-fix-ocl
dnn: add exhaustive fusion tests, enable more eltwise fusions

* add eltwise fusion tests, enable more eltwise fusions

* merge weighted eltwise tests with eltwise tests
2020-08-13 10:55:41 +00:00
Pierre-Emmanuel Viel 3f55152ca0 Add debug assert to check in FLANN the vectors size is multiple of the architecture word size 2020-08-12 23:07:35 +02:00
Liubov Batanina f3cebb3e1b Merge pull request #18077 from l-bat:reduce_sum
* Supported ReduceSum op

* Skip test
2020-08-12 14:32:16 +00:00
Alexander Alekhin 2b227f00f2 Merge pull request #18074 from pemmanuelviel:pev--kmeans-refactoring 2020-08-12 13:18:20 +00:00
Pierre-Emmanuel Viel 98de57c6c4 Refactoring to prepare for other vector types while mutualizing some methods 2020-08-12 00:57:37 +02:00
zhaoyue-zephyrus e231be86b7 support flownet2 with arbitary input size
revise default proto to match the filename in documentations

fix a bug

beautify python codes

fix bug

beautify codes

add test samples with larger/smaller size

remove unless code

using bytearray without creating tmp file

remove useless codes
2020-08-12 00:50:58 +08:00
Elizarov Ilya 7ec221e734 Merge pull request #18033 from ieliz:dasiamrpn
Improving DaSiamRPN tracker sample

* changed layerBlobs in dnn.cpp and added DaSiamRPN tracker

* Improving DaSiamRPN tracker sample

* Docs fix

* Removed outdated changes

* Trying to reinitialize tracker without reloading models. Worked with LaSOT-based benchmark with reinit rate=250 frames

* Trying to reverse changes

* Moving the model in the constructor

* Fixing some issues with names

* Variable name changed

* Reverse parser arguments changes
2020-08-11 11:46:47 +03:00
pemmanuelviel fe9ff64d64 Merge pull request #17643 from pemmanuelviel:pev--new-flann-demo
* Add a FLANN example showing how to search a query image in a dataset

* Clean: remove warning

* Replace dependency to boost::filesystem by calls to core/utils/filesystem

* Wait for escape key to exit

* Add an example of binary descriptors support

* Add program options for saving and loading the flann structure

* Fix warnings on Win64

* Fix warnings on 3.4 branch still relying on C++03

* Add ctor to img_info structure

* Comments modification

* * Demo file of FLANN moved and renamed

* Fix distances type when using binary vectors in the FLANN example

* Rename FLANN example file

* Remove dependency of the flann example to opencv_contrib's SURF.

* Remove mention of FLANN and other descriptors that aimed at giving hint on the other options

* Cleaner program options management

* Make waitKey usage minimal in FLANN example

* Fix the conditions order

* Use cv::Ptr
2020-08-10 13:26:40 +00:00
Alexander Alekhin 3f65c12d0c Merge pull request #17982 from nglee:dev_cudaGpuMatConvertToInplaceFix 2020-08-09 20:21:17 +00:00
Alexander Alekhin 336627a776 Merge pull request #18048 from l-bat:onnx_torchvision 2020-08-06 20:21:47 +00:00
Liubov Batanina 6226ea0085 Fix bug in ONNX Gather op 2020-08-06 15:47:34 +03:00
Alexander Alekhin 1067cd0649 Merge pull request #18036 from alalek:backport_17858 2020-08-04 20:16:22 +00:00
Vadim Pisarevsky 1537ecd931 * added depth-wise convolution; gives ~20-30% performance improvement in MobileSSD networks
* hopefully, eliminated compile warnings, errors, as well as failure in one test

* * fixed a few typos
* decreased buffer size in some cases
* added more optimal im2row branch in the case of 1x1 convolutions
* tuned fastConv to reduce the number of passes over arrays

backport of commit 77b01deb80
2020-08-04 17:34:48 +00:00
Alexander Alekhin 5b5c42d2c7 Merge pull request #18027 from dkurt:dnn_backport_ngraph 2020-08-04 16:24:11 +00:00
Alexander Alekhin 161890dad4 Merge pull request #18017 from danielenricocahall:add-relu-to-darknet 2020-08-04 16:17:07 +00:00
Alexander Alekhin 35846fe735 Merge pull request #18008 from gsmatos:document-patchnans 2020-08-04 16:15:53 +00:00
Gabriel 96ce65f021 Document PatchNANs input type 2020-08-03 22:57:18 -03:00
danielenricocahall 8457e471fd add relu as activation option in darknet
add relu option

add relu as activation option in darknet

simplify the setParams if-else ladder

add relu as activation option in darknet

correct activation_param type

format

format

add relu as activation option in darknet

spacing

spacing

add relu as activation option in darknet
2020-08-03 19:19:35 -04:00
Ilya Churaev 246de2b7f5 Replaced copy_with_new_args to clone_with_new_inputs 2020-08-03 23:08:29 +03:00
Ilya Churaev e8c26963e9 Fixed removing is_parameter, is_constant, is_output 2020-08-03 23:08:22 +03:00
pemmanuelviel 793e7c0d9f Merge pull request #18019 from pemmanuelviel:pev--multiple-kmeans-trees
* Possibility to set more than one tree for the hierarchical KMeans (default is still 1 tree).

This particularly improves NN retrieval results with binary vectors, allowing better quality
compared to LSH for similar processing time when speed is the criterium.

* Add explanations on the FLANN's hierarchical KMeans for binary data.
2020-08-03 18:29:57 +00:00
Alexander Alekhin 3b337a12c9 Merge pull request #18018 from danielenricocahall:add-compose-panorama-python-binding 2020-08-03 18:28:18 +00:00
Alexander Alekhin 2c32cb743c Merge pull request #18016 from pemmanuelviel:pev--cleaner-hierarchical-clustering 2020-08-03 18:27:11 +00:00
Alexander Alekhin 883b995fd6 Merge pull request #18012 from sturkmen72:update_doc_and_sample 2020-08-03 18:26:12 +00:00
Alexander Alekhin a28533933f Merge pull request #17998 from dkurt:dnn_fix_ngraph 2020-08-03 18:23:11 +00:00
Liubov Batanina d695208727 Merge pull request #17967 from l-bat:non_const_weights_for_conv
* Supported convolution with non-const weights

* Fix opencl blobs

* Update tests
2020-08-03 18:02:49 +00:00
kadi soheib 613ff61de7 Added reference to paper. 2020-08-03 18:07:36 +03:00
Alexander Alekhin 65b02cc8f2 Merge pull request #17742 from SoheibKadi/DetectionOutput_layer_doc
Adding comment from source code to DetectionOutputLayer class documentation
2020-08-03 17:17:04 +03:00
Alexander Alekhin 1c8ee3f957 Merge pull request #17885 from alalek:dnn_ocl_slice_update
DNN: OpenCL/slice update

* dnn(ocl/slice): make slice kernel VTune friendly

- more unique names
- inline code of copy functions

* dnn(ocl/slice): prefer to spawn more work groups

- even in case with 1D copy
- perf improvement up to 2x of kernel time (due to changed configuration 128x1x1 => 128x32x1)

* dnn(ocl/slice): cache kernel exec info
2020-08-03 14:13:34 +00:00
Yosshi999 922108060d Merge pull request #17907 from Yosshi999:gsoc_asift-py2cpp
* Implement ASIFT in C++

* '>>' should be '> >' within a nested template

* add a sample for asift usage

* bugfix empty keypoints cause crash

* simpler initialization for mask

* suppress the number of lines

* correct tex document

* type casting

* add descriptorsize for asift

* smaller testdata for asift

* more smaller test data

* add OpenCV short license header
2020-08-03 14:11:55 +00:00
Alexander Alekhin ce74285c5e Merge pull request #17478 from tomoaki0705:dropOldCC 2020-08-03 13:00:41 +00:00
Suleyman TURKMEN c262eea84a Update warpPerspective_demo.cpp 2020-08-03 12:14:01 +03:00
danielenricocahall f2ca7e664a add python binding and tests for composePanorama
fix tests

    pick 54039c2afd add python binding and tests for composePanorama
2020-08-02 19:29:16 -04:00
Dmitry Kurtaev cf8f65d806 Do not use size_t for nGraph layers 2020-08-02 20:50:44 +03:00
Pierre-Emmanuel Viel bc221bdb90 Cleaner code for hierarchical_clustering 2020-08-02 18:05:54 +02:00
kadi soheib 6bed5c181b Corrected Comment as requested by reviewer. 2020-07-31 23:43:38 +03:00
Maksim Shabunin f162c08cda Merge pull request #17987 from mshabunin:fix-xcode-carotene 2020-07-31 09:08:10 +00:00
Maksim Shabunin 0d1d452b79 Merge pull request #17983 from Windfisch:Windfisch-patch-jpeg2000 2020-07-31 09:07:35 +00:00
Pavel Rojtberg 3c3e131c38 Merge pull request #17977 from paroj:hervec
* calib3d: calibrateHandEye - allow using Rodrigues vectors for rotation

* calib3d: calibrateHandEye - test rvec representation
2020-07-30 22:59:15 +03:00
Maksim Shabunin a218cf3c61 Merge pull request #17957 from AnnaPetrovicheva:ap/update-logo 2020-07-30 19:56:32 +00:00
Maksim Shabunin 866468cc3e Fix Carotene compilation with XCode 2020-07-30 22:52:29 +03:00
Florian Jung f66fc199a2 Fix build of grfmt_jpeg2000.cpp
libjasper has recently changed `jas_matrix_get` from a macro to an inline function
(389951d071 in https://github.com/jasper-software/jasper), causing the build to fail.
2020-07-30 19:23:52 +02:00
Namgoo Lee 11ac26bfb4 test code 2020-07-30 01:42:44 +09:00
Namgoo Lee 2241bfb0df Use "src" not "*this" for source GpuMat 2020-07-30 01:03:34 +09:00
Tomoaki Teshima d92af2aa85 * stop showing old generations
* keep it possible to build for old CC
  * make sure old generations don't come up for the choice
  * remove related version check of old one
2020-07-29 17:31:39 +09:00
Alexander Alekhin e4d573a080 Merge pull request #17916 from SinM9:mish_functor_sin 2020-07-28 17:05:59 +00:00
Anna Petrovicheva f86c8656a3 Updated the OpenCV logo 2020-07-28 18:31:21 +03:00
Maksim Shabunin 6697f0ea86 Merge pull request #17925 from sturkmen72:patch-2 2020-07-28 13:18:16 +00:00
Maksim Shabunin e935f06f16 Merge pull request #17928 from sturkmen72:update_samples 2020-07-27 08:32:25 +00:00
Maksim Shabunin 1e18004bdd Merge pull request #17943 from tomoaki0705:fixPolarToCartRounding 2020-07-27 08:32:03 +00:00
Tomoaki Teshima 19646ad049 let the test pass on Jetson 2020-07-25 23:45:51 +09:00
Suleyman TURKMEN 7e943808b6 Update train_HOG.cpp 2020-07-23 20:23:31 +03:00
Suleyman TURKMEN 88dbee3589 Update samples 2020-07-23 20:09:37 +03:00
Maksim Shabunin 5bfa43f7d5 Merge pull request #17489 from Lapshin:ffmpeg_cap_consider_rotation_metadata_3.4 2020-07-23 08:35:51 +00:00
Alexander Smorkalov 7ed37b3fa5 MP4 autorotation tests and various fixes for Windows
- Added test for automated rotation for  MP4 videos with metadata
- Fix 180 degrees rotation bug
- Moved rotation logic to cv::VideoCapture implementation for FFmpeg and restore binary compatibility with FFmpeg wrapper.
2020-07-23 09:30:18 +03:00
Alexey Lapshin f0271e54d9 Autorotation for mp4 streams with metadata
- Add VideoCapture camera orientation property for mp4 videos with camera orientation meta.
- Add auto rotation for 90, 180, 270 degrees using cv::rotate
2020-07-23 09:27:04 +03:00
Sinitsina 0ac2f0e04c mish_functor_update 2020-07-23 09:02:00 +03:00
Maksim Shabunin ef1690ef45 Merge pull request #17913 from asmorkalov:as/connected_components_ref 2020-07-22 16:06:23 +00:00
Maksim Shabunin 0fa06b1db0 Merge pull request #17863 from nglee:dev_cudaDetachOutput 2020-07-22 08:19:32 +00:00
Alexander Smorkalov abceef74e0 Added reference to Original Wu's articte about SAUF connected components search method. 2020-07-22 10:05:55 +03:00
Maksim Shabunin 5444a6b11c Merge pull request #17890 from l-bat:onnx_gather 2020-07-21 09:38:35 +00:00
Namgoo Lee 9411cd6c07 Use in-place npp function for inplace arguments 2020-07-21 10:27:43 +09:00
Liubov Batanina a35d4f9029 Support Gather for variable inputs 2020-07-20 14:02:45 +03:00
Alexander Alekhin 284d26da05 Merge tag '3.4.11' 2020-07-17 02:06:19 +00:00
Alexander Alekhin e8d4259f9a release: OpenCV 3.4.11 2020-07-17 00:34:46 +00:00
Alexander Alekhin 8086afc60a Merge pull request #17865 from alalek:add_missing_check_17036 2020-07-17 00:28:33 +00:00
Alexander Alekhin b2ebd37ee2 Merge pull request #17856 from alalek:dnn_openvino_2020.4.0 2020-07-16 20:08:00 +00:00
Alexander Alekhin 83e6813345 imgproc: add missing check into cvtColorTwoPlane() 2020-07-16 20:01:44 +00:00
Alexander Alekhin 09f24a851e Merge pull request #17764 from alalek:issue_17762 2020-07-16 15:27:21 +00:00
Alexander Alekhin 81e027eef7 dnn: fix OpenCL implementation of Slice layer 2020-07-16 04:33:52 +00:00
Alexander Alekhin 1c371d07b5 dnn(test): adjust tests for OpenVINO 2020.4 2020-07-15 23:47:40 +00:00
Alexander Alekhin 55e8549839 dnn: eliminate IE deprecation warning 2020-07-15 23:39:06 +00:00
Alexander Alekhin f8d6c5b330 winpack_dldt: switch defaults to OpenVINO 2020.4 2020-07-15 22:13:19 +00:00
Alexander Alekhin 435b6df989 dnn: use OpenVINO 2020.4 defines
original commit: 2813aa7eb9
2020-07-15 20:13:40 +00:00
Alexander Alekhin bf8136eaa6 Merge pull request #17849 from dkurt:fix_17848 2020-07-15 18:53:46 +00:00
Dmitry Kurtaev cc584760d3 Fix TensorFlow->ONNX imports 2020-07-15 14:36:13 +03:00
Alexander Alekhin d41b20b268 Merge pull request #17830 from alalek:fix_17815 2020-07-13 18:52:34 +00:00
Alexander Alekhin 36da867caf features2d: v_fma => v_muladd for integers 2020-07-13 17:31:08 +00:00
Alexander Alekhin c5f540e3d7 Merge pull request #17806 from alalek:dnn_ie_num_threads_windows 2020-07-13 17:12:31 +00:00
pemmanuelviel c90e824342 Merge pull request #17639 from pemmanuelviel:pev--binary-kmeans
Pev binary kmeans

* Ongoing work transposing kmeans clustering method for bitfields: the computeClustering method

Ongoing work transposing kmeans clustering method for bitfields: interface computeBitfieldClustering

Fix genericity of computeNodeStatistics

Ongoing work transposing kmeans clustering method for bitfields: adapt computeNodeStatistics()

Ongoing work transposing kmeans clustering method for bitfields: adapt findNN() method

Ongoing work transposing kmeans clustering method for bitfields: allow kmeans with Hamming distance

Ongoing work transposing kmeans clustering method for bitfields: adapt distances code

Ongoing work transposing kmeans clustering method for bitfields: adapt load/save code

Ongoing work transposing kmeans clustering method for bitfields: adapt kmeans hierarchicalClustring()

PivotType -> CentersType Renaming

Fix type casting for ARM SIMD implementation of Hamming

Fix warnings with Win32 compilation

Fix warnings with Win64 compilation

Fix wrong parenthesis position on rounding

* Ensure proper rounding when CentersType is integral
2020-07-13 12:59:10 +00:00
jasonKercher 749bd80091 Merge pull request #17770 from jasonKercher:3.4_triggered
3.4 Allow first capture to return false

* fix first capture timeout

* fix first capture timeout
2020-07-13 12:29:54 +00:00
Alexander Alekhin 1c0b70bbd2 Merge pull request #17822 from alalek:issue_17792 2020-07-13 11:08:33 +00:00
Alexander Alekhin b75f6c05c0 Merge pull request #17805 from tomoaki0705:fixCUDAHostCompilerIssue 2020-07-12 13:05:14 +00:00
Tomoaki Teshima 269b810601 re-enable automatic CC detection on Jetson
* treat both CMAKE_C_COMPILER and c_compiler_realpath as candidate
2020-07-12 21:22:12 +09:00
Alexander Alekhin e54040d540 core: use lazy on-demand initialization for param_traceEnable 2020-07-12 11:53:46 +00:00
Alexander Alekhin b96e9a4a4a Merge pull request #17800 from Yosshi999:gsoc_sift-universal-intrinsic 2020-07-11 19:09:21 +00:00
Alexander Alekhin e18df87a15 Merge pull request #17635 from jsxyhelu:3.4 2020-07-10 15:11:53 +00:00
Alexander Alekhin 5cb8619eca dnn(ie): enable KEY_CPU_THREADS_NUM for Windows 2020-07-10 14:29:21 +00:00
jsxyhelu 476094ad5a Use“ moms” replace "contourArea"
double area = moms.m00;
is same as
double area = contourArea(contours[contourIdx]);
Not to mention
"moms" already calculated here,"contourArea" should not apply
2020-07-10 11:05:24 +00:00
Alexander Alekhin d2469edd10 Merge pull request #17772 from mshabunin:fix-match-umat-mask 2020-07-10 10:53:56 +00:00
Yosshi999 0df8fb70b4 use bufferarea for allocating buffer 2020-07-09 16:50:20 +00:00
Maksim Shabunin 4dd9a36a3c Added test for checkMasks with UMat train descs 2020-07-09 16:22:19 +03:00
Maksim Shabunin 41678fe3d3 Fixed checkMasks in DescriptorMatcher with train descs in UMats 2020-07-09 16:05:20 +03:00
Alexander Alekhin 5bc6b6fc26 Merge pull request #17737 from pemmanuelviel:pev--fix-trees-descent 2020-07-08 20:59:29 +00:00
Alexander Alekhin 8931c68b20 Merge pull request #17707 from Yosshi999:gsoc_sift-universal-intrinsic 2020-07-08 20:33:40 +00:00
Alexander Alekhin f78f908c09 Merge pull request #17674 from alalek:issue_16214 2020-07-08 20:01:35 +00:00
Alexander Alekhin 5487bca4f3 Merge pull request #17777 from alalek:backport_cuda_cmake 2020-07-08 20:00:13 +00:00
Alexander Alekhin 762a5c8334 imgproc: align GaussianBlur/sepFilter2D OpenCL with CPU version 2020-07-08 15:13:48 +00:00
Alexander Alekhin 2fed41dfa5 imgproc(test): test bitExact cases in OCL/sepFilter2D 2020-07-08 10:14:56 +00:00
Alexander Alekhin e0f9eac521 cmake: backport CUDA scripts 2020-07-08 07:33:54 +00:00
Alexander Alekhin b90a2a8497 Merge pull request #17759 from alalek:build_opencv_winpack_dldt_2020.4.0 2020-07-07 19:28:53 +00:00
Alexander Alekhin 950a916952 Merge pull request #17752 from YashasSamaga:generalize-concat-fusion-3.4 2020-07-07 10:36:02 +00:00
Alexander Alekhin 3f13339071 Merge pull request #17728 from sturkmen72:patch-4 2020-07-06 23:01:27 +00:00
Alexander Alekhin eb6678ebef Merge pull request #17699 from alalek:build_core_cuda
* core(cuda): fix build

- MSVS 19.25.28612.0
- CUDA release 11.0, V11.0.167

* cmake(cuda): backport workaround for CUDA 11

* cmake(cuda): call CUDA_BUILD_CLEAN_TARGET() on finalize

* cmake(cuda): use CMAKE_SUPPRESS_REGENERATION with MSVS
2020-07-06 22:58:17 +00:00
Alexander Alekhin d62e0a3695 Merge pull request #17743 from alalek:test_17666 2020-07-06 22:36:35 +00:00
Alexander Alekhin dcb7fd8520 Merge pull request #17766 from alalek:backport_17756 2020-07-06 21:50:24 +00:00
Alexander Alekhin d5713c657b dnn(slice): disable buggy OCV/OCL implementation 2020-07-06 21:36:19 +00:00
Alexander Alekhin 99c4b76a6d dnn(test): add YOLOv4-tiny tests 2020-07-06 21:36:19 +00:00
Alexander Alekhin e4887aaa5b Merge pull request #17761 from mshabunin:test-wo-jpg-png 2020-07-06 20:02:15 +00:00
Ilya Churaev d69a7a3bbf Fixed header paths for some nGraph ops
* Added dependency on IE version

backport of commit: 992c908b56
2020-07-06 19:51:57 +00:00
Alexander Alekhin ccf6dd07b3 build: winpack_dldt with dldt 2020.4.0 2020-07-06 14:08:54 +00:00
Maksim Shabunin e8129429e9 imgcodecs: fix test build with disabled JPEG and PNG libs 2020-07-06 14:52:52 +03:00
Suleyman TURKMEN 2566d13100 Update documentation of imwrite() 2020-07-06 11:02:50 +03:00
Alexander Alekhin 5a15369d4d Merge pull request #17729 from modeste2015:3.4 2020-07-04 17:17:57 +00:00
Alexander Alekhin deaf1dd458 Merge pull request #17724 from pemmanuelviel:pev--fix-mix-of-types 2020-07-04 17:16:57 +00:00
pemmanuelviel 65f87b114b Merge pull request #17722 from pemmanuelviel:pev--replace-asserts
* Clean: replace C style asserts by CV_Assert and CV_DbgAssert

* Try fixing warning on Windows compilation

* Another way trying to fix warnings on Win

* Fixing warnings with some compilers:
Some compilers warn on systematic exit preventing to execute the code that follows.
This is why assert(0) that exits only in debug was working, but not CV_Assert or CV_Error
that exit both in release and debug, even if with different behavior.
In addition, other compilers complain when return 0 is removed from getKey(),
even if before we have a statement leading to systematic exit.

* Disable "unreachable code" warnings for Win compilers so we can use proper CV_Error
2020-07-04 20:15:44 +03:00
Alexander Alekhin 8f5b453a96 Merge pull request #17719 from pemmanuelviel:pev--fix-computeNodeStatistics-genericity 2020-07-04 17:14:35 +00:00
YashasSamaga b7eec216e9 generalize axis for concat fusion 2020-07-04 18:57:28 +05:30
kadi soheib 17c430da88 Updated comment. 2020-07-04 06:37:59 +03:00
kadi soheib 96a501c08b Adding comment from source code to documentation. 2020-07-04 06:37:58 +03:00
Alexander Alekhin dc57707e60 Merge pull request #17744 from alalek:issue_17657 2020-07-03 21:21:27 +00:00
Alexander Alekhin 56b5a7d977 cmake: fix ENABLE_PROFILING 2020-07-03 19:31:41 +00:00
Liubov Batanina 65dbbf712d Merge pull request #17733 from l-bat:tiny_yolov4
* Supported yolov4-tiny

* Added comments
2020-07-03 18:07:08 +00:00
Alexander Alekhin 49497d8e7c Merge pull request #17725 from pemmanuelviel:pev--precompute-divisor 2020-07-03 11:24:11 +00:00
Pierre-Emmanuel Viel 728684840c Fix trees parsing behavior in hierarchical_clustering_index:
Before, when maxCheck was reached in the first descent of a tree, time was still wasted parsing
the next trees till their best leaves whose points were not used at all.
2020-07-03 01:19:10 +02:00
Alexander Alekhin 73f7d091f8 Merge pull request #17721 from pemmanuelviel:pev--fix-hist-intersect-arguments 2020-07-02 11:54:28 +00:00
Ken Shirriff 00e1bc49c8 Merge pull request #17708 from shirriff:patch-1
Clarify component statistics documentation

* Change ConnectedComponentsTypes documentation

Change from "algorithm output formats" to "statistics" because it specifies types of statistics, not formats.

* Documentation: clarify component statistics

Explain that ConnectedComponentTypes selects a statistic.
2020-07-02 13:58:53 +03:00
Heritier Kinke cb3a098b25 forget to look in sub folder of include/openblas 2020-07-02 03:33:07 +02:00
Alexander Alekhin 5a7045181a Merge pull request #17723 from pemmanuelviel:pev--remove-duplicate 2020-07-01 18:14:08 +00:00
Pierre-Emmanuel Viel 6a045fd678 Fix arguments list in loadindex for histogram intersection 2020-07-01 18:59:45 +02:00
Pierre-Emmanuel Viel 327f92cc46 Precompute the divisor to ensure that no kind of compiler would process it on the fly at each call. 2020-07-01 18:52:05 +02:00
Pierre-Emmanuel Viel 482cacd420 Mix of 32 and 64bits vector types prevents vectorisation for distance computation.
Argument "a" is of type ElementType* that is either int* or float*, while b was double*.
Mixing types prevents the possibility to use SSE or AVX instructions.
On implementation without SIMD instructions, this doesn't show any impact on performance.
2020-07-01 18:27:07 +02:00
Pierre-Emmanuel Viel 93a6be836c Remove duplicate line 2020-07-01 18:15:01 +02:00
Pierre-Emmanuel Viel ef7185ce43 Fix genericity of computeNodeStatistics that couldn't compute stats properly on sub-nodes 2020-07-01 12:14:15 +02:00
Yosshi999 920c180052 use universal SIMD intrinsics for SIFT 2020-06-30 06:44:12 +00:00
Alexander Alekhin a84afb6334 Merge pull request #17640 from pemmanuelviel:pev--fix-lsh-bad-any-cast 2020-06-29 20:53:34 +00:00
Pierre-Emmanuel Viel cdac7c7bec Add test checking we don't throw when creating GenericIndex with LshIndexParams() 2020-06-28 19:51:04 +00:00
Pierre-Emmanuel Viel fe09c79f4b Fix the 'cvflann::anyimpl::bad_any_cast' error using Lsh 2020-06-28 19:51:04 +00:00
Alexander Alekhin cabad90d6c Merge pull request #17636 from okamotoR:3.4 2020-06-27 20:17:16 +00:00
Alexander Alekhin 6dba1733f0 Merge pull request #17567 from dev-tronifier:new_branch 2020-06-27 20:08:37 +00:00
pemmanuelviel daa88c6b9e Merge pull request #17642 from pemmanuelviel:pev--fixes-and-clean
* Clean: make the use of the indices array length consistent

Either we don't want this method to be used in the future for any other node
than the root node, and so we replace indices_length by size_ and remove it as
argument, or we want to be able to use it potentially for other nodes, and
so using size_ instead of indices_length would have lead to a bug.

* Fix: b was not an address

* Fix: transpose the Flann repo commit "Fixes in accum_dist methods" from Adil Ibragimov

Avoids trying to compute log(ratio) with ratio = 0

* Fix: transpose the Flann repo commit "result_set bugfix" from Jack Rae

* Fix Jack Rae commit as the initial i - 1 index was decremented before entering the loop body

* Clean: transpose the Flann repo commit "Updated comments in lsh_index" from Richard McPherson

* Fix: Transpose the Flann repo commit "Fixing unreachable code in lsh_table.h" from hypevr

* Fix warning the same way it was done in flann standalone repo

* Change the return value in case of unsupported type
2020-06-26 22:34:52 +00:00
dev-tronifier 9b727fa1f3 Increased portability of CV_Func 2020-06-26 19:45:58 +00:00
Alexander Alekhin e45d74c8f9 Merge pull request #17638 from pemmanuelviel:pev--avoid-branching-in-loop 2020-06-26 19:22:20 +00:00
Alexander Alekhin 923009b5ff Merge pull request #17663 from alalek:backport_17658 2020-06-26 17:41:53 +00:00
Yosshi999 4064d4c7eb Merge pull request #17618 from Yosshi999:gsoc_sift-better-test
Added/Fixed testcases for SIFT

* merge perf_sift into conventional perf tests

* Fix disabled SIFT scale invariance tests

allows trainIdx duplication in matching scaled keypoints
2020-06-25 11:34:31 +00:00
Ilya Lavrenov e58ce89b10 Conditional compilation for IR v7 support
backported commit 86905754e4
2020-06-25 10:05:14 +00:00
Alexander Alekhin 6259ba1bfd Merge pull request #17641 from pemmanuelviel:pev--fix-middleSplit-for-kdtree-single 2020-06-25 09:12:40 +00:00
Alexander Alekhin cd8262eb79 Merge pull request #17650 from alalek:update_libjpeg-turbo 2020-06-24 10:57:37 +00:00
Alexander Alekhin d2b854674e Merge pull request #17648 from alalek:update_libjpeg 2020-06-24 10:57:07 +00:00
Alexander Alekhin ad930f6216 3rdparty: libjpeg-turbo 2.0.4 => 2.0.5
https://github.com/libjpeg-turbo/libjpeg-turbo/releases/tag/2.0.5
2020-06-24 06:28:16 +00:00
Alexander Alekhin f061a0ab36 3rdparty: libjpeg 9d
http://www.ijg.org/files/jpegsrc.v9d.tar.gz
2020-06-23 20:35:56 +00:00
Alexander Alekhin 2e165053ef Merge pull request #17624 from dkurt:dnn_optimize_mish 2020-06-23 18:43:51 +00:00
Alexander Alekhin 8cc8b0d2b4 Merge pull request #17633 from alalek:backport_17616 2020-06-23 18:29:55 +00:00
Pierre-Emmanuel Viel 06b4292534 Fix: error in the dimension used for computeMinMax
Instead of using the current dimension for which we just got a big span,
we were computing Min and Max for the previous dimension stored in cutfeat
(and using 0 instead of the dimension indice for the very first dimension
with "span > (1-eps)max_span")
2020-06-23 15:47:27 +02:00
Pierre-Emmanuel Viel 29f883feee Optim: test that could be done once has been extracted from the loop 2020-06-23 15:43:38 +02:00
okamotoR 0e69cddda2 add if block for indexed color images 2020-06-23 21:36:47 +09:00
Ilya Lavrenov ad5e70f94e Conditional compilation for network reader
origibal commit: 63e92cccf2
2020-06-23 14:15:52 +03:00
Alexander Alekhin 7fae2e834c Merge pull request #17622 from dkurt:dnn_ie_cpu_ext_update 2020-06-23 11:01:47 +00:00
Dmitry Kurtaev 8e3f5fb209 Remove deprecated Inference Engine CPU extensions 2020-06-23 10:10:29 +03:00
Pierre-Emmanuel Viel 05fbd1e5bc DNA mode: add the distance computations 2020-06-22 22:53:05 +02:00
Dmitry Kurtaev 1491934d17 Optimize Mish for CPU backend 2020-06-22 23:27:47 +03:00
Alexander Alekhin fce486c4f9 Merge pull request #17592 from l-bat:disable_nms_in_yolo_layer 2020-06-22 10:31:33 +00:00
Alexander Alekhin 1b4955342f Merge pull request #17599 from tomoaki0705:fixCUDAFailSafePath 2020-06-21 17:49:14 +00:00
Tomoaki Teshima 95ac650af6 make the fail safe path actually safe
* use only supported CC in the list
  * workaround of #17526
2020-06-21 07:20:47 +09:00
Alexander Alekhin 2b98aa403e Merge pull request #17593 from tomoaki0705:addAmpereCUDA 2020-06-20 22:01:36 +00:00
Alexander Alekhin 425c653a14 Merge pull request #17580 from sitic:bibfix 2020-06-19 21:35:07 +00:00
Tomoaki Teshima 52844614c4 add Ampere CC
* Ampere has CC 8.0
  * Arm64 server support has been added in CUDA 11 (only V100 for now)
2020-06-19 20:46:18 +09:00
Liubov Batanina 85c0c8c7ed Disabling dafault NMS in yolo layer 2020-06-19 14:34:13 +03:00
Jan Lebert a8f04359e8 docs: linkfix in bibliography
The [current link](https://arxiv.org/pdf/1808.01752) goes to a
random unrelated paper.
2020-06-19 11:44:35 +02:00
Alexander Alekhin cb54f4c2ec Merge pull request #17587 from tomoaki0705:fixCUDAOptflowJetson 2020-06-19 07:21:19 +00:00
Tomoaki Teshima 77fa1a20bf fix build on Jetson TX1 and TX2
* enable_if_t is a c++14 feature
2020-06-19 07:56:37 +09:00
Alexander Alekhin a7cdc42140 Merge pull request #17581 from tomoaki0705:fixCudaAsync 2020-06-18 20:54:28 +00:00
Alexander Alekhin a8aa9d5ecb Merge pull request #17578 from Bleach665:fix_win_eigen_build 2020-06-18 20:52:33 +00:00
Alexander Alekhin 52fbfb3ec0 Merge pull request #17577 from philippefoubert:branch_color_yuv_simd 2020-06-18 20:51:52 +00:00
Philippe FOUBERT d25293b721 Fix the build of imgproc using MinGW (variables with the same name as symbols defined in MinGW headers) 2020-06-18 20:13:34 +00:00
Tomoaki Teshima c07af090f5 fix build error on Jetson TX1 and TX2
* enable_if_t and is_base_of is c++14 feature
 * override is c++11 feature
2020-06-18 21:25:15 +09:00
Yuriy Obukh 456e88a8a4 fix VS Windows build with eigen. https://github.com/opencv/opencv/issues/17548 2020-06-18 14:31:11 +03:00
Alex Cohn a7cc1159cd Merge pull request #17573 from alexcohn:fix/android_windows_build
* fixing #17572

https://github.com/opencv/opencv/issues/17572 Build for Android failed: "can't concat str to bytes"

on Windows 10 64bit with python 3.6.6

* similar to changes in platforms/winpack_dldt/build_package.py
2020-06-18 10:40:43 +03:00
Alexander Alekhin 6bd87e8146 Merge pull request #17571 from tomoaki0705:fixAutomaticCC 2020-06-18 07:39:14 +00:00
Alexander Alekhin 42a4c3fba6 Merge pull request #17568 from alalek:cleanup_17527 2020-06-18 07:38:16 +00:00
Tomoaki Teshima 1cba763189 fix build error of automatic CC detection 2020-06-17 22:02:51 +09:00
Alexander Alekhin d01cbe9320 cudacodec(build): fix detection in CMake, cleanup duplicate includes 2020-06-17 09:09:40 +00:00
NesQl b10ab79743 Merge pull request #17468 from liqi-c:sharedlib_build_problem
TEngine installation rules fix for static build

* Modify cmake config error for -DBUILD_SHARED_LIBS=OFF

* Modify for not install tengine include directory

* Update compile error.

* move install command to tengine/CMakeLists.txt

* rm include dir when make install,only build static lib will install libtengine.a
2020-06-17 09:05:04 +00:00
Alexander Alekhin 619462b029 Merge pull request #17564 from l-bat:fix_yolov4 2020-06-17 08:45:56 +00:00
Liubov Batanina d93b6be3cc Changed StridedSlice to VariadicSplit in Region layer 2020-06-17 10:02:53 +03:00
Alexander Alekhin 9755ab160d Merge pull request #17556 from nglee:dev_optFlowTVL1Async 2020-06-16 20:06:56 +00:00
Namgoo Lee 2043e06102 cuda optflow tvl1 : async safety
also modify cuda canny to use createTextureObjectPitch2D, etc.
2020-06-17 01:04:22 +09:00
Alexander Alekhin c7dcdc0e88 Merge pull request #17557 from alalek:backport_17554 2020-06-15 19:26:11 +00:00
Alexander Alekhin eb67dc9f50 Merge pull request #17533 from alalek:fix_dumpInputArray_nd_case 2020-06-15 18:38:19 +00:00
Ilya Lavrenov 676b818d6a Removed plugin dispatcher
backport of commit 74113737f3
2020-06-15 18:03:14 +00:00
Namgoo Lee 411ce04f54 CUDA_OptFlow/OpticalFlowDual_TVL1 Asynchronous test 2020-06-16 01:43:51 +09:00
Alexander Alekhin d321a34f7c Merge pull request #17527 from tomoaki0705:detectCuvidHeader 2020-06-14 11:08:16 +00:00
Alexander Alekhin fb1a58ac76 Merge pull request #17537 from Murazaki:patch-1 2020-06-13 18:36:34 +00:00
Alexander Alekhin 1644af841b Merge pull request #17536 from ilya-lavrenov:remove-error-listener 2020-06-12 22:18:04 +00:00
Mehdi Zakaria Benadel b0def9617f Fix typo
This typo just made me lose my mind on the conan package update. please merge.
2020-06-12 23:52:06 +02:00
Alexander Alekhin c2664d912a Merge pull request #17538 from alalek:dnn_openvino_2020.3.0 2020-06-12 21:24:35 +00:00
Ilya Lavrenov 9697e3ac24 Removed error lisneter usage 2020-06-12 20:29:11 +00:00
Alexander Alekhin d2a9efd039 dnn: use OpenVINO 2020.3 defines 2020-06-12 20:24:08 +00:00
Alexander Alekhin 442999dcdb core: fix handling of ND-arrays in dumpInputArray() helpers 2020-06-12 10:23:32 +00:00
Alexander Alekhin d753ae1489 Merge pull request #17143 from cyyever:detect_mkl_installed_by_nuget 2020-06-12 09:44:42 +00:00
cyy db3e3be8ee improve the mkl search procedure 2020-06-12 06:59:27 +00:00
Alexander Alekhin 0c8da03869 Merge pull request #17341 from hunter-college-ossd-spr-2020:3.4-1 2020-06-12 06:58:14 +00:00
Jessica Wong 0417c8c9c7 Added information to OpenCV documentation [MacOS]
Added and Edited specific information to the "Installation in MacOS" OpenCV documentation.
Closes #17340
2020-06-11 23:36:06 -04:00
Tomoaki Teshima d4af89781b fix corner case of libnvcuvid
* detect header automatically and not based on version number
2020-06-11 23:06:18 +09:00
Alexander Alekhin a8c1cdf88e Merge pull request #17511 from mshabunin:fix-kw-issues-34 2020-06-10 12:13:06 +00:00
Maksim Shabunin 7a187e9b5e QRDetectMulti: refactored checkPoints method 2020-06-10 13:48:24 +03:00
Maksim Shabunin 9096b1c768 dnn/NGraph: added nullptr checks 2020-06-10 13:48:24 +03:00
Rasmus 781fbde449 Merge pull request #17368 from themightyoarfish:cv2eigen-doc
* Add documentation about usage of cv2eigen functions in eigen.hpp

* Fixed Doxygen syntax.

Co-authored-by: Alexander Smorkalov <smorkalov.a.m@gmail.com>
2020-06-10 07:53:18 +00:00
Gourav Roy 1b336bb602 Merge pull request #16955 from themechanicalcoder:text_recognition
* add text recognition sample

* fix pylint warning

* made changes according to the c++ example

* fix errors

* add text recognition sample

* update text detection sample
2020-06-10 06:53:18 +00:00
Alexander Alekhin 0fb3b8db72 Merge pull request #17504 from alalek:update_ffmpeg_3.4 2020-06-09 07:51:59 +00:00
Alexander Alekhin b44302382d ffmpeg/3.4: update FFmpeg wrapper
- FFmpeg 3.4.7
2020-06-08 21:03:05 +00:00
Alexander Alekhin 458f1d5ebe Merge pull request #17501 from alalek:update_version_3.4.11-pre 2020-06-08 19:35:34 +00:00
Alexander Alekhin a43e3bebe6 pre: OpenCV 3.4.11 (version++) 2020-06-08 18:46:27 +00:00
Alexander Alekhin f62fe956d1 Merge pull request #17498 from alalek:update_tbb 2020-06-08 18:38:57 +00:00
Alexander Alekhin 852b0226e0 3rdparty: update TBB 2020.1 => 2020.2
https://github.com/oneapi-src/oneTBB/releases/tag/v2020.2
2020-06-08 11:04:33 +00:00
Alexander Alekhin ef3844a177 Merge pull request #17466 from alalek:build_opencv_winpack_dldt_2020.3.0 2020-06-04 17:32:09 +00:00
Alexander Alekhin 476aa443c6 Merge pull request #17432 from tomoaki0705:automaticCC 2020-06-04 17:10:04 +00:00
Fernando Martin cb0f74ab9f Merge pull request #17473 from f3rm4rf3r:fixingFourCCDocBrokenLink
* - Fixing broken URL to mp4ra website

* - Fixing broken URL to mp4ra website (in C videoio API)
2020-06-04 17:07:54 +00:00
Alexander Alekhin 08d1c54364 Merge pull request #17469 from l-bat:fix_virtual_try_on 2020-06-04 10:32:30 +00:00
Alexander Alekhin dbbfa003d3 Merge pull request #17455 from mshabunin:check-count-non-zero 2020-06-04 08:47:43 +00:00
Liubov Batanina 5ffc5bca7c Fixed virtual try on sample 2020-06-04 09:41:24 +03:00
Alexander Alekhin 11ac2e1475 build: winpack_dldt with dldt 2020.3.0
https://github.com/openvinotoolkit/openvino/releases/tag/2020.3.0
2020-06-04 01:21:16 +00:00
Maksim Shabunin 59608907b8 Added countNonZero test for big arrays and disable IPP for some cases 2020-06-03 18:58:41 +03:00
Alexander Alekhin e454c4891e Merge pull request #17369 from themightyoarfish:doc-essential-matrix-different-cameras 2020-06-03 12:55:55 +00:00
Alexander Alekhin 3ed243abde Merge pull request #17430 from alalek:issue_17257 2020-06-02 12:42:04 +00:00
Alexander Alekhin d60524ecfa Merge pull request #17447 from alalek:dnn_ie_extract_layers 2020-06-02 12:40:06 +00:00
Rasmus Diederichsen 345e071b24 Add instructions for how to use findEssentialMat() when camera matrices are different 2020-06-02 12:19:49 +03:00
Alexander Alekhin be1a121d0d dnn(ie): fix layers extraction 2020-06-01 21:57:39 +00:00
Tomoaki Teshima 156406b56c select the architecture based on nvcc result
* cache the result
  * DRY
  * brush up based on review
2020-06-02 05:07:53 +09:00
Alexander Alekhin f68654a204 Merge pull request #17438 from alalek:fix_eigen_builds 2020-06-01 18:02:07 +00:00
Vadim Pisarevsky 8abb312c20 Merge pull request #17417 from vpisarev:fix_fitellipse
* improved fitEllipse and fitEllipseDirect accuracy in singular or close-to-singular cases (see issue #9923)

* scale points using double precision

* added normalization to fitEllipseAMS as well; fixed Java test case by raising the tolerance (it's unclear what is the correct result in this case).

* improved point perturbation a bit. make the code a little bit more clear

* trying to fix Java fitEllipseTest by slightly raising the tolerance threshold

* synchronized C++ version of Java's fitEllipse test

* removed trailing whitespaces
2020-06-01 18:01:20 +00:00
Alexander Alekhin adcb943f61 Merge pull request #17424 from berak:dnn_sample_human_parsing 2020-06-01 17:58:13 +00:00
Vadim Pisarevsky 5489735258 Merge pull request #17436 from vpisarev:fix_python_io
* fixed #17044
1. fixed Python part of the tutorial about using OpenCV XML-YAML-JSON I/O functionality from C++ and Python.
2. added startWriteStruct() and endWriteStruct() methods to FileStorage
3. modifed FileStorage::write() methods to make them work well inside sequences, not only mappings.

* try to fix the doc builder

* added Python regression test for FileStorage I/O API ([TODO] iterating through long sequences can be very slow)

* fixed yaml testing
2020-06-01 11:33:09 +00:00
Alexander Alekhin 8de176988d Merge pull request #17439 from alalek:fix_dnn_test_required_file 2020-05-31 19:51:56 +00:00
Alexander Alekhin 79c5d07abe dnn(test): file 'dnn/efficientdet-d0.pb' is optional 2020-05-31 16:18:37 +00:00
Alexander Alekhin 74020a084b core: fix builds with eigen helper header 2020-05-31 15:41:42 +00:00
berak 09acd478f1 dnn: add a human parsing cpp sample 2020-05-31 09:50:20 +02:00
Alexander Alekhin e6c9e2fa50 Merge pull request #17420 from nosajthenitram:fix_cascadedetect_convert_bug_for_old_cascade 2020-05-30 17:34:20 +00:00
Meng Wang ab2c59b80e Merge pull request #17403 from wangmengHB:master
Fix Test Case: in latest version, window.cv is a promise instance that makes most test case failed.

* Fix Browser Test Case: In latest version, window.cv is a promise instance

In latest version of opencv.js, window.cv is promise instance.
So that most of the test cases is run failed.
This commit is to fix browser test case.

* Add comment for backward compatible

Add comments for backward compatible
2020-05-30 17:33:17 +00:00
Jason Martin a5209c4882 Fixed cascadedetect convert from old cascade to new 2020-05-30 11:45:24 -05:00
Alexander Alekhin f1dd5e49c5 videoio(ffmpeg): fix handling of AVERROR_EOF
decoder should be properly flushed after that
2020-05-29 19:52:26 +00:00
Alexander Alekhin c6b60e219d Merge pull request #17428 from asmorkalov:as/java_smart_constructors 2020-05-29 18:38:34 +00:00
Alexander Alekhin 740f6628ec Merge pull request #17419 from YourButterfly:fix_divide_zero_in_darknet_3_4 2020-05-29 17:32:48 +00:00
Alexander Smorkalov 821fac187c Generate constructor with smart pointer, if it's expected. 2020-05-29 16:40:19 +03:00
Alexander Alekhin 73fdf75328 Merge pull request #17338 from hunter-college-ossd-spr-2020:contours-toc 2020-05-29 10:40:43 +00:00
YourButterfly f7daa9e4f5 chk divide 0 2020-05-29 09:54:46 +08:00
Alexander Alekhin e58e545584 Merge pull request #17392 from alalek:dnn_test_yolov4 2020-05-28 22:52:21 +00:00
Alexander Alekhin 319db07b6b Merge pull request #17384 from dkurt:efficientdet 2020-05-28 22:48:52 +00:00
Alexander Alekhin 407cc5f1b6 Merge pull request #17416 from vpisarev:fix_fillpoly 2020-05-28 21:37:15 +00:00
Vadim Pisarevsky 80037dc6de fixed fillPoly, the overloaded variant with InputArrayOfArrays parameter (single or multiple polygons) 2020-05-28 21:36:28 +03:00
Dmitry Kurtaev d9bada9867 dnn: EfficientDet 2020-05-28 17:23:42 +03:00
Alexander Alekhin 6b89154afd dnn(test): add YOLOv4 tests 2020-05-28 13:27:40 +00:00
Alexander Alekhin 1f2d4e4839 Merge pull request #17410 from asmorkalov:as/formulae_command_typo 2020-05-28 11:45:19 +00:00
Alexander Smorkalov 4a9904fe62 Command name typo fix for formulas in documentation. 2020-05-28 13:59:31 +03:00
Alexander Alekhin 4b5fdc6bb2 Merge pull request #17406 from mshabunin:fix-msmf-audio-handling 2020-05-27 19:20:39 +00:00
Maksim Shabunin 2d11edd103 videoio/MSMF: fixed audio stream handling 2020-05-27 17:57:18 +03:00
Ningxin Hu fef6192bca Merge pull request #17394 from huningxin:fix_segmentation_py
* Fix window title of python segmentation example

* Fix float text position of python segmentation examples
2020-05-27 11:20:07 +03:00
Alexander Alekhin 7d9e1be588 Merge pull request #17388 from alalek:dnn_update_network_dump 2020-05-27 07:55:32 +00:00
Liubov Batanina ba3cf47600 Merge pull request #17386 from l-bat:tf_clamp_subgraph
* Added ClipByValue subgraph

* Return const nodes
2020-05-26 19:01:47 +00:00
Alexander Alekhin 9e09828cc3 Merge pull request #17390 from l-bat:fix_ngraph_multiply 2020-05-26 16:33:12 +00:00
Liubov Batanina b236f10792 Switch ngraph::op::v1::Multiply to v0 2020-05-26 16:59:50 +03:00
Alexander Alekhin f0bef94a03 dnn: update network dump code, include ngraph serialization 2020-05-26 12:49:22 +00:00
Egor Pugin 1bec7ca540 Merge pull request #17352 from egorpugin:patch-2
* Fix integer overflow in parseOption().

Previous code does not work for values like 100000MB.

* Fix warning during 32-bit build on inactive code path.

* fix build without C++11
2020-05-25 20:25:18 +00:00
Alexander Alekhin 29bbbaa0a7 Merge pull request #17376 from alalek:dnn_fix_build 2020-05-25 19:59:58 +00:00
Alexander Alekhin 73aa5f567b dnn: *_DENORMALS_ZERO_MODE is defined for SSE3 2020-05-25 17:55:36 +00:00
Liubov Batanina d5e8792f55 Merge pull request #17332 from l-bat:fix_nms
Fixed NMSBoxes bug

* Added NMS for each class

* Updated cpp sample

* Fixed errors

* Refactoring

* Added NMS for IE
2020-05-25 12:34:11 +00:00
Michal W. Tarnowski 5393185add Merge pull request #17360 from mwtarnowski:fix-documentation-imgproc-blur
* fix documentation for cv::blur

* correct the position of ksize parameter
2020-05-24 22:46:41 +00:00
Josh Bradley 9fef09fe89 Merge pull request #17320 from jgbradley1:add-eigen-tensor-conversions
* add eigen tensor conversion functions

* add eigen tensor conversion tests

* add support for column major order

* update eigen tensor tests

* fix coding style and add conditional compilation

* fix conditional compilation checks

* remove whitespace

* rearrange functions for easier reading

* reformat function documentation and add tensormap unit test

* cleanup documentation of unit test

* remove condition duplication

* check Eigen major version, not minor version

* restrict to Eigen v3.3.0+

* add documentation note and add type checking to cv2eigen_tensormap()
2020-05-23 18:25:01 +00:00
Alexander Alekhin a9b030591b Merge pull request #17295 from dkurt:dnn_fusion_ftz 2020-05-22 18:49:43 +00:00
Alexander Alekhin d4a9c731ff Merge pull request #17345 from alalek:build_fix_mac_warnings 2020-05-22 10:50:41 +00:00
Alexander Alekhin 17d15df6cd Merge pull request #17343 from hunter-college-ossd-spr-2020:mac-install 2020-05-22 08:12:10 +00:00
Alexander Alekhin 98611adeb9 build: fix warnings about TARGET_OS_MACCATALYST 2020-05-21 20:41:47 +00:00
Alexander Alekhin 01a8c9ca8d Merge pull request #17331 from allnes:update_quirc 2020-05-21 20:15:55 +00:00
Boubacar 0940c56a3f add note on cmake brew install 2020-05-21 10:34:17 -04:00
Alexander Alekhin d650b5cc5a Merge pull request #17339 from hunter-college-ossd-spr-2020:pylint-note 2020-05-21 13:53:29 +00:00
Boubacar b624da27bd add pylint install note 2020-05-21 07:55:11 -04:00
Boubacar 5b443199ca group contour articles together 2020-05-21 07:16:54 -04:00
Alexander Alekhin cb82388a84 Merge pull request #17325 from hunter-college-ossd-spr-2020:nav-links 2020-05-20 18:14:27 +00:00
Nesterov Alexander 735c31bb4a Resolve type conflict 2020-05-20 18:05:27 +03:00
Nesterov Alexander b7253e3280 Update version quirc 2020-05-20 17:55:14 +03:00
Daniel Mallia 94d187e269 Add next and previous navigation links to all tutorials 2020-05-19 18:59:28 -04:00
Liubov Batanina d991c22090 Merge pull request #16575 from l-bat:flownet2
Support FlowNet2 model

* Support DataAugmentation layer

* Fix warnings

* Fix comments

* Support Correlation layer

* TEST

* Support Correlation layer

* Supported Accum and FlowWarp layers

* Supported ChannelNorm layer

* Supported Resample with inputs.size() > 1

* Fixed comments

* Refactoring

* Added tests

* Add resample test

* Added asserts in resize layer

* Updated DataAugmentation layer

* Update convolution layer

* Refactoring

* Fix data augmentation layer

* Fix caffe importer

* Fix resize

* Switch to Mat ptr

* Remove useless resize type

* Used ResizeLayer in Accum

* Split ChannelNormLayer

* Delete duplicate assert

* Add sample

* Fix sample

* Added colormap
2020-05-19 12:29:50 +00:00
Alexander Alekhin 322960f795 Merge pull request #17297 from dkurt:dnn_yolov3_ocl 2020-05-18 17:47:16 +00:00
Dmitry Kurtaev b5035ce991 Increase test threshold for YOLOv3 on OCL FP16 2020-05-18 19:06:15 +03:00
dmallia17 07c56f149f Merge pull request #17313 from hunter-college-ossd-spr-2020:revise-knn-tutorials
* Revise and expand kNN Python tutorials

* Correct NPTEL link
2020-05-18 15:53:17 +00:00
Alexander Alekhin 0e1c7eda39 Merge pull request #17092 from alalek:imgproc_ipp_parallel_gaussuanBlur 2020-05-18 11:51:59 +00:00
Alexander Alekhin 2b2bcc9b38 Merge pull request #17304 from chrisballinger:maccatalyst 2020-05-17 20:33:05 +00:00
Alexander Alekhin a3b109eca0 imgproc: enable GaussianBlur IPP parallel processing 2020-05-17 11:40:34 +00:00
Alexander Alekhin a1b09a3734 imgproc(perf): add GaussianBlur cases for SIFT 2020-05-17 10:15:31 +00:00
Chris Ballinger d81ac52ce2 Remove linking against AssetsLibrary framework 2020-05-16 12:47:50 -07:00
Chris Ballinger 220df8252d Add target conditionals for Mac Catalyst 2020-05-16 12:47:50 -07:00
Alexander Alekhin de720ac34a Merge pull request #17294 from alalek:issue_17247 2020-05-16 18:49:22 +00:00
Dmitry Kurtaev 68d59a2913 Flush to zero Convolution denormal weights 2020-05-15 23:44:34 +03:00
Alexander Alekhin 753e417dec Merge pull request #17299 from tweenietomatoes:patch-1 2020-05-15 15:48:46 +00:00
tweenietomatoes 7d1094b7e1 Important single character fix 2020-05-15 14:41:55 +03:00
Alexander Alekhin 58426c80a3 samples: fix OpenCL events leaks 2020-05-14 17:15:09 +00:00
Ganesh Kathiresan cddd7f10d5 Merge pull request #17224 from ganesh-k13:bugfix/calib3d/17201
* Fixed indexing in prefilter

* Initialised prefilter

* Initialised prefilter with value initialisation

* Added TC to trigger different Mem Allocs in BufferBM

* Optimize cases with only needed conditions
2020-05-14 16:30:01 +00:00
Alexander Alekhin ea3c2307dc Merge pull request #17248 from nroduit:java-addall 2020-05-14 12:17:51 +00:00
Alexander Alekhin 65b3209441 Merge pull request #17055 from vnikoofard:patch-1 2020-05-14 12:17:26 +00:00
Nicolas Roduit 400a781ebf Prefer addall instead of iteration for performance 2020-05-14 11:42:24 +03:00
Alexander Alekhin c8689d9d0a Merge pull request #17288 from dkurt:dnn_tf_resize_down 2020-05-14 07:08:41 +00:00
Alexander Alekhin ea0d1424d8 Merge pull request #17287 from tomoaki0705:fixAkazeTestFailureMali 2020-05-14 06:59:28 +00:00
Alexander Alekhin 365f44b094 Merge pull request #17285 from sauhaardac:patch-1 2020-05-14 06:58:42 +00:00
Alexander Alekhin bcf96d637e Merge pull request #17284 from dkurt:dnn_bn_fusion 2020-05-14 06:57:36 +00:00
Alexander Alekhin 6ced54a892 Merge pull request #17281 from l-bat:ssd_placeholder_shape 2020-05-14 06:55:52 +00:00
Liubov Batanina c5a2d28367 Determine SSD input shape 2020-05-14 08:16:45 +03:00
Dmitry Kurtaev b4a6aa335d TensorFlow bilinear resize downscale 2020-05-13 23:59:20 +03:00
Tomoaki Teshima 35245cb76e fix test failure on Mali T760 and Mali T628 2020-05-14 05:44:14 +09:00
Sauhaarda Chowdhuri fa349b7a4e Fix #17279 Documentation Error
Update documentation to solve #17279. Simple documentation bug.
2020-05-13 13:14:05 -07:00
Dmitry Kurtaev df305e83fa Fix BatchNorm reinitialization after fusion 2020-05-13 22:15:36 +03:00
Alexander Alekhin b2464e3379 Merge pull request #17270 from l-bat:ngraph_missed_data 2020-05-13 08:27:04 +00:00
Alexander Alekhin 6856cc7253 Merge pull request #17228 from mshabunin:mfx-surface-pool-34 2020-05-12 19:00:49 +00:00
Alexander Alekhin 508bd3f55d Merge pull request #17260 from jsxyhelu:add_deepgreen_colormap 2020-05-12 18:58:54 +00:00
Alexander Alekhin 8b51e2df8b Merge pull request #17211 from alalek:sift_dispatch 2020-05-12 18:53:35 +00:00
Alexander Alekhin bd1b252de9 Merge pull request #17196 from alalek:core_matexpr_fix_warning 2020-05-12 18:50:58 +00:00
Maksim Shabunin f30931848e CAP_MFX: surface pool with timeout, more parameters 2020-05-12 18:43:04 +03:00
Liubov Batanina b27ae9c63b Switch v1::Multiply to v0::Multiply 2020-05-12 16:05:03 +03:00
Liubov Batanina 79f8b7fd73 Merge pull request #17233 from l-bat:onnx_bn
* Added ONNX BatchNorm subgraph

* Move removing constant inputs to addConstantNodesForInitializers

* Added initializers to ONNXGraphWrapper
2020-05-12 15:33:57 +03:00
jsxyhelu 48e9e651a4 add DeepGreen colormap 2020-05-12 15:24:32 +03:00
Alexander Alekhin 1bf353b876 Merge pull request #17230 from asmorkalov:as/issue_17171 2020-05-12 10:53:23 +00:00
Alexander Alekhin 23e336ee53 Merge pull request #17244 from hunter-college-ossd-spr-2020:toc-updates 2020-05-12 07:35:14 +00:00
Alexander Alekhin ac54bb193c Merge pull request #17256 from R-penguins:jstutfix 2020-05-12 07:34:00 +00:00
Rui Hou e9058ea8f5 Easier access to opencv.js in tutorial 2020-05-10 11:20:27 -04:00
Alexander Alekhin fd06139c20 Merge pull request #17235 from R-penguins:patch-1 2020-05-10 08:16:34 +00:00
R-penguins b43da8aa5d Update Image Watch Tutorial
Updated the Windows Visual Studio Image Watch tutorial to include download links to the latest versions of Visual Studio Image Watch for newer Visual Studio versions.
2020-05-09 23:24:47 -04:00
Alexander Alekhin 066259b656 Merge pull request #17118 from l-bat/concat_3d
Added NDHWC Concat support for TensorFlow

* Supported TF concat 3d

* Skip myriad

* Fix test
2020-05-09 22:24:06 +03:00
Alexander Alekhin 64f5471b2a Merge pull request #17208 from hn-88:3.4 2020-05-08 18:31:11 +00:00
Daniel Mallia 4e789635c9 Update tutorials tables of content for several modules 2020-05-08 14:22:30 -04:00
Alexander Smorkalov 7c17695be4 Added Java and C++ regression test for estimateNewCameraMatrixForUndistortRectify. 2020-05-08 13:04:25 +03:00
Alexander Alekhin 73bbabcd04 Merge pull request #17223 from hunter-college-ossd-spr-2020:imgproc-toc 2020-05-07 08:44:02 +00:00
Alexander Alekhin 93d79d2e5d Merge pull request #17219 from hunter-college-ossd-spr-2020:mathjax-link 2020-05-07 08:43:16 +00:00
Alexander Alekhin 1889d72889 Merge pull request #17218 from hunter-college-ossd-spr-2020:numpy-links-17212 2020-05-07 08:42:50 +00:00
Alexander Alekhin 5813d2439c Merge pull request #17222 from dkurt:dnn_flexible_slice 2020-05-06 19:46:34 +00:00
Alexander Alekhin 4f1ba5e69e Merge pull request #16941 from rngtna:examples_dnn_text_decoder 2020-05-06 22:45:05 +03:00
Daniel Mallia c934d9c3cc Update imgproc tutorials table of content Languages fields 2020-05-06 13:07:24 -04:00
Aleksandr Pertovskiy 00b19d6fba Add text recognition example 2020-05-06 15:26:17 +03:00
Dmitry Kurtaev 8b13b85c5e dnn: Slice with variable input shapes 2020-05-05 13:35:17 +03:00
Daniel Mallia 64b0757758 Update Supported formula commands - MathJax link 2020-05-04 23:50:22 -04:00
Daniel Mallia 1622e7cc90 Update NumPy links 2020-05-04 23:20:52 -04:00
Alexander Alekhin 1f9713195b features2d(sift): enable runtime dispatching 2020-05-03 11:59:27 +00:00
hn-88 ea04f9d12e to make OpenCV compile on mingw32
added #define NO_DSHOW_STRSAFE
2020-05-03 11:19:04 +05:30
Alexander Alekhin 74e4cfd1da core(MatExpr): fix warning in case of e.s == (0, 0, 0, 0) 2020-05-01 07:29:57 +00:00
Alexander Alekhin 27ee6501eb Merge pull request #17188 from asmorkalov:as/fisheye_test 2020-04-30 13:55:31 +00:00
Liubov Batanina a5696da9ec Merge pull request #17185 from l-bat:yolo_v4
* Support Yolov4

* Skip Mish on OpenVINO 2020.2

* Revert Mish

* Refactoring
2020-04-30 16:53:44 +03:00
Alexander Alekhin 0b439bcd08 Merge pull request #17190 from alalek:dnn_test_win32_skip_list 2020-04-29 20:53:54 +00:00
Alexander Alekhin b805115c1a dnn(test): update skip tests on Win32 configuration 2020-04-29 20:02:13 +00:00
Alexander Smorkalov c41fb45da3 Restored test disabled during 3.0-alpha preparation. 2020-04-29 17:08:51 +03:00
QIU Xiaochen cdfa58dde0 Merge pull request #17180 from PetWorm:3.4
* fix Scharr nomination
2020-04-29 09:55:59 +00:00
Alexander Alekhin 6630eac813 Merge pull request #17173 from tomoaki0705:fixOclHogDetect 2020-04-28 16:36:14 +00:00
Tomoaki Teshima 63f5f93063 fix test failure on ODROID-N2 2020-04-28 21:46:31 +09:00
Alexander Alekhin 5da4bb7e88 Merge pull request #16983 from dkurt:dnn_tf_prelu 2020-04-28 08:37:46 +00:00
Alexander Alekhin dc1b1f2cd7 Merge pull request #16914 from jackson0223:patch-1 2020-04-28 08:36:51 +00:00
Dmitry Kurtaev 25ec4ce6f1 PReLU from Tensorflow 2020-04-28 00:01:21 +03:00
jackson0223 d30bc0a4c0 Restore face detection train.prototxt from #9516 2020-04-27 23:07:33 +03:00
Alexander Alekhin c05ac8729e features2d: keep history of simd.cpp 2020-04-27 18:19:14 +00:00
Alexander Alekhin 9926a93a78 features2d: copy sift.dispatch.cpp 2020-04-27 18:18:16 +00:00
Alexander Alekhin 7093752cb5 features2d: copy sift.simd.hpp 2020-04-27 18:17:15 +00:00
Alexander Alekhin 0daf055fe6 Merge pull request #17159 from pauljurczak:patch-3 2020-04-27 12:43:32 +00:00
Alexander Alekhin 3f38edfd61 Merge pull request #17161 from alalek:cmake_protobuf_fix 2020-04-27 12:24:37 +00:00
Alexander Alekhin ee201f4df5 Merge pull request #17157 from alalek:issue_17138 2020-04-27 12:23:44 +00:00
Alexander Alekhin 9181ecfc7b cmake: fix protobuf handling 2020-04-27 02:11:19 +00:00
Liubov Batanina 4bf94cb5d1 Fix test 2020-04-26 20:42:11 +03:00
Paul Jurczak 599a3026d1 Added to Camera constructor parameter description 2020-04-26 00:17:39 -06:00
Alexander Alekhin 288fa70ed9 dnn(protobuf): backport AllowUnknownField(), SetRecursionLimit()
- limit recursion in SkipField*() calls
2020-04-25 20:45:43 +00:00
Alexander Alekhin 8d05dab32c Merge pull request #17119 from alalek:move_sift 2020-04-24 18:15:15 +00:00
Alexander Alekhin 3c14a8c507 Merge pull request #17149 from alalek:core_simd_suppress_coverity 2020-04-24 17:46:54 +00:00
Alexander Alekhin ab3b1e9922 Merge pull request #17108 from HowardsPlayPen:patch-1 2020-04-24 17:25:31 +00:00
Alexander Alekhin cd7db168e0 core(SIMD): suppress coverity UNINIT_CTOR on SIMD vectors 2020-04-24 16:36:35 +00:00
HowardsPlayPen cbcdbde29d Update videocapture_basic.cpp
I believe you are using the wrong version of open() on line 28 - adding deviceID + appId together. It's better to use the new version of .open() taking two integers as parameter.
2020-04-24 11:42:45 +03:00
Alexander Alekhin 2df978b8e7 Merge pull request #17134 from alalek:dnn_ie_avoid_conversion_to_legacy 2020-04-23 22:39:45 +00:00
Alexander Alekhin 10808ccbb4 Merge pull request #17129 from alalek:dnn_myriad_tests 2020-04-23 19:41:15 +00:00
Alexander Alekhin f756923271 dnn(ie): avoid conversion to legacy CNNNetworkImpl 2020-04-23 19:11:33 +00:00
Alexander Alekhin a327418767 features2d(sift): move SIFT tests / headers / build fixes 2020-04-23 08:45:22 +00:00
Alexander Alekhin 83c4378d5d dnn(test): skip failed NGRAPH/MYRIAD tests 2020-04-22 15:00:23 +00:00
Alexander Alekhin e74075c689 Merge pull request #16887 from ashishkrshrivastava:fasterrcnn 2020-04-22 09:47:45 +00:00
Liubov Batanina 1c1762d3f6 Skip myriad 2020-04-22 09:52:20 +03:00
ashishiva3@gmail.com e0ac0cfbe2 add fused batchNorm Upsample 2020-04-22 08:24:17 +05:30
Alexander Alekhin 775d031366 Merge pull request #17123 from ganesh-k13:bugfix/documentation/3.4/16987 2020-04-21 21:03:36 +00:00
Alexander Alekhin 1a17f402a4 Merge pull request #17030 from ashishkrshrivastava:onnximporter 2020-04-21 21:02:41 +00:00
Polina Smolnikova 40973bea31 Merge pull request #16961 from rayonnant14:objdetect_different_return_value_issue
QRDetectMulti : different return value bug fix

* QRDetectMulti : bug fix

* added tests

* changed test image due to large size of previous test image
2020-04-21 20:44:50 +00:00
Ganesh Kathiresan 0be2c7018b Formula Fixes for 3.4 branch
Foumula fix 1

Foumula fix 2

Foumula fix 3

Foumula fix 4

Foumula fix 5

Foumula fix 8
2020-04-21 19:23:23 +05:30
Liubov Batanina aa08900ac8 Supported TF concat 3d 2020-04-21 15:15:22 +03:00
AshihsKrShrivastava d37180a2c4 modification for upsample node fused from unfused Resize subgraph 2020-04-21 15:03:00 +05:30
Liubov Batanina 8badf7f354 Merge pull request #17112 from l-bat:ie_region
* Support nGraph Region

* Support region since OpenVINO 2020.2

* Skip myriad
2020-04-21 09:26:58 +00:00
Alexander Alekhin 150bd3aee6 Merge pull request #17106 from pauljurczak:patch-3 2020-04-20 18:00:01 +00:00
Paul Jurczak a748eba42e Added descriptions of randu and randn 2020-04-20 07:13:37 +00:00
Alexander Alekhin 935420217c Merge pull request #17102 from dkurt:dnn_ie_flexible_inputs 2020-04-19 18:06:09 +00:00
Alexander Alekhin 81d4d4948e Merge pull request #17105 from benji1123:pointPolygonTest_demo 2020-04-19 17:38:23 +00:00
Ben 041da57e87 fix tuple error 2020-04-19 10:36:59 -04:00
Alexander Alekhin acf1be547d Merge pull request #17046 from alalek:core_inputarray_matexpr_cleanup 2020-04-18 21:41:59 +00:00
Dmitry Kurtaev 908bf935f7 Flexible inputs for OpenVINO IR models 2020-04-18 20:00:22 +03:00
Alexander Alekhin e59e978fcd Merge pull request #17096 from spectralio:java-cmake-fix 2020-04-17 21:24:41 +00:00
Alexander Alekhin fbaae7ac37 Merge pull request #17041 from alalek:core_simd_vector_ctors 2020-04-17 21:22:08 +00:00
Alexander Alekhin dcf7eb972e core(SIMD): align behavior of vector constructors
- setzero() calls are dropped due low-level API nature
- initialization is mandatory if necessary (not an output of other calls)
2020-04-17 14:34:34 +00:00
Maksim Shabunin 2840362868 Merge pull request #16769 from mshabunin:fix-ipp-install
* Do not copy standalone IPP libraries to install for static builds

* Restored IPP installation under option
2020-04-17 14:28:42 +00:00
jshiwam d4fc302c7e Merge pull request #16795 from jshiwam:qrsample
Added a sample file for qrcode detection in python

* sample python file for qrcode detection added in samples/python

* input taken using argparse and the indents were removed

* Removed unused variables

* updated the format and removed unused variables

Removed the use of global variables and used parameterised contructor instead

=set multi detection true by default

* added detection from camera

* samples(python): coding style in qrcode.py
2020-04-17 12:16:39 +00:00
spectralio 1cce9db710 fix missing underscore 2020-04-17 13:08:32 +02:00
Alexander Alekhin e92f1eaa3d Merge pull request #17071 from mshabunin:tickmeter-fps 2020-04-17 08:56:29 +00:00
Maksim Shabunin f84cae833a TickMeter: added FPS and AvgTime, improved docs, reformatted 2020-04-16 21:33:29 +03:00
Alexander Alekhin ed58b5489f [move sift.cpp] sift: avoid inplace calls of GaussianBlur
- should unlock IPP optimizations

original commit: https://github.com/opencv/opencv_contrib/commit/ce7c8f2646ccf3f5e657ab1241e22c0c32cd9d41
2020-04-16 17:58:45 +00:00
Alexander Alekhin ef5fa498d4 [move sift.cpp] sift: perf tests and trace regions
original commit: https://github.com/opencv/opencv_contrib/commit/a15e105db12aa7a0bade47afb791682201e46f60
2020-04-16 17:58:45 +00:00
Alexander Alekhin 78e4fbd2d7 Merge pull request #17091 from tomoaki0705:fixHOGDetectorFailure 2020-04-16 16:34:45 +00:00
Tomoaki Teshima 96075ce0c9 avoid test failure on Arm platform 2020-04-17 00:59:15 +09:00
Alexander Alekhin c007228d0f Merge pull request #17075 from alalek:dnn_updates_from_openvino_2020.2 2020-04-16 12:19:58 +00:00
Alexander Alekhin dca9b4283b Merge pull request #17080 from dkurt:dnn_ngraph_future 2020-04-16 11:19:08 +00:00
Alexander Alekhin dcec3150f0 Merge pull request #17084 from tomoaki0705:fixQRInputCheck 2020-04-16 09:44:08 +00:00
Alexander Alekhin d015db3de8 Merge pull request #17083 from pauljurczak:patch-2 2020-04-16 09:43:44 +00:00
Alexander Alekhin ef7fb905aa Merge pull request #17074 from AlanLi7991:doc/python-svm-doc-formula-miss 2020-04-16 09:43:20 +00:00
Dmitry Kurtaev 5e5385a814 Remove NodeVector for nGraph 2020-04-16 11:13:49 +03:00
Alanli 7aaa918367 doc: formula miss 2020-04-16 09:05:00 +09:00
Tomoaki Teshima c2e484a465 fix wrong condition check 2020-04-16 08:24:14 +09:00
Paul Jurczak f64d807863 Added to description of WCube constructor
`WCube` constructor reorders `min_point`, `max_point` parameters when necessary. I added this info to the description.
2020-04-15 16:06:14 -06:00
Alexander Alekhin 81c2f3d194 Merge pull request #17081 from alalek:backport_17056 2020-04-15 18:33:41 +00:00
Alexander Alekhin 8c77f35fce Merge pull request #17079 from tomoaki0705:fixCUDABgSgmMOG 2020-04-15 18:30:09 +00:00
Alexander Alekhin ff4ce9f7b1 build: winpack_dldt with dldt 2020.2 2020-04-15 17:25:23 +00:00
Tomoaki Teshima f39784c584 fix test failure on Jetson TX2 2020-04-15 23:25:12 +09:00
Alexander Alekhin 98e38b2a41 Merge pull request #17017 from VadimLevin:dev/vlevin/header-parser-explicit-support 2020-04-15 12:53:42 +00:00
Vadim Levin 1d8c73cf6c feature: Added explicit support to header parser
- It is safe to remove `explicit` keyword for constructors with 1
argument, because it is C++ specific keyword and does not affect any of
the generated binding.
2020-04-15 14:25:39 +03:00
Alexander Alekhin ef68cc3d5f dnn: use OpenVINO 2020.2 defines
original commit: 45263d7642
2020-04-15 11:14:43 +00:00
Vadim Levin 18550b4601 test: Added tests for VideoCapture constructors in java 2020-04-15 14:12:31 +03:00
Alexander Alekhin c8f1948d58 core: drop EXPR handing code in InputArray 2020-04-14 18:02:19 +00:00
Alexander Alekhin f6de25b6cb Merge pull request #17060 from dkurt:dnn_align_ie_pool 2020-04-14 15:15:44 +00:00
Alexander Alekhin b3514a5708 Merge pull request #17049 from ilya-lavrenov:il/nn-builder 2020-04-14 15:14:35 +00:00
Ilya Lavrenov 91b0100287 Fixed compilation when NN builder is not built 2020-04-14 15:05:01 +03:00
Dmitry Kurtaev 870a775d7d Align DLIE and nGraph average pooling layers 2020-04-14 13:54:54 +03:00
Vahid Nikoofard 575a609b80 Update calcBackProject_Demo1.py
To round a ndarray it's necessary to use np.round() instead to Built-in Python round()
2020-04-14 00:23:53 -03:00
Alexander Alekhin 675342ecd9 Merge pull request #17025 from tomoaki0705:fixTestFailureCUDABruteForceNonLocalMeans 2020-04-13 18:17:50 +00:00
Alexander Alekhin 245b2fec34 Merge pull request #16925 from dkurt:dnn_ssd.pytorch 2020-04-13 13:12:12 +00:00
Alexander Alekhin 49a75079f2 Merge pull request #17047 from alalek:fix_permissions 2020-04-13 12:34:08 +00:00
Dmitry Kurtaev d3f9ad1145 Enable ONNX SSD from https://github.com/amdegroot/ssd.pytorch 2020-04-13 15:12:27 +03:00
Alexander Alekhin 46615ffc4a Merge pull request #16985 from ashishkrshrivastava:padfusion 2020-04-13 11:26:13 +00:00
Alexander Alekhin f0ffc52435 fix files permissions 2020-04-13 04:29:55 +00:00
Alexander Alekhin f7d029cfce Merge pull request #17039 from tomoaki0705:fixCudaImgprocFailure 2020-04-12 17:15:49 +00:00
Tomoaki Teshima 1eb63cfc42 fix test failure on Jetson TX1/TX2/Nano 2020-04-12 23:58:53 +09:00
Alexander Alekhin 43ff8f8e8d Merge pull request #17006 from tpoisonooo:patch-1 2020-04-11 17:24:36 +00:00
tpoisonooo b11a3a0820 Update grfmt_pxm.cpp
remove comment in .ppm
2020-04-11 17:41:51 +03:00
AshihsKrShrivastava bef6b6282c ReflecitonPad2d and ZeroPad2d Subgraph fusion added 2020-04-11 07:14:05 +05:30
Alexander Alekhin 9c58a7cb1e Merge pull request #16653 from alalek:core_inputarray_matexpr 2020-04-10 16:57:17 +00:00
Alexander Alekhin 69ac19d82d Merge pull request #17023 from poelmanc:patch-1 2020-04-10 16:32:15 +00:00
Conrad Poelman b77fe9d624 Remove std::binary_function as it's invalid C++
std::binary_function was deprecated with C++11 and removed in C++17. It provided just two typedefs which in this case were unused.
2020-04-10 16:16:52 +03:00
Xiping Yan 5c7c80dd27 Merge pull request #17028 from xipingyan:patch-1
* Update OpenCVFindVA_INTEL.cmake

When set env VA_INTEL_IOCL_ROOT, "if($ENV{VA_INTEL_IOCL_ROOT})" don't work.
    My modification as follow.
    
    -    if($ENV{VA_INTEL_IOCL_ROOT})
    +    if(DEFINED ENV{VA_INTEL_IOCL_ROOT})
    
    Refer: https://cmake.org/cmake/help/latest/variable/ENV.html

* based on merge comment, update code
2020-04-10 12:23:13 +00:00
Alexander Alekhin d7abb641ca core(test): add InputArray(MatExpr) fetch test 2020-04-10 11:35:42 +00:00
Tomoaki Teshima 4e75f31c55 fix test failure on Jetson Nano/TX1/TX2 2020-04-10 06:15:16 +09:00
Alexander Alekhin e1f14fcac7 Merge pull request #16975 from shimat:Branch_4.3.0 2020-04-09 08:28:20 +00:00
shimat 39d3bbb601 fix error at #include <window_winrt_bridge.hpp> 2020-04-09 09:54:13 +09:00
Alexander Alekhin 4d35a46c48 Merge pull request #17010 from alalek:issue_16896 2020-04-08 14:50:00 +00:00
Alexander Alekhin 2c9d149ac2 Merge pull request #16993 from asmorkalov:as/faq_wiki 2020-04-08 13:56:57 +00:00
Alexander Alekhin 06bf845783 Merge pull request #16979 from dkurt:dnn_fused_resize_conv 2020-04-08 13:29:51 +00:00
Alexander Smorkalov f496a37340 Migrated FAQ page to Github Wiki 2020-04-08 13:55:44 +03:00
Alexander Alekhin b745e1c43a Merge pull request #17014 from dkurt:dnn_onnx_elu 2020-04-08 10:18:33 +00:00
Dmitry Kurtaev 21ed892489 Fix Elu import from ONNX 2020-04-08 12:09:45 +03:00
Alexander Alekhin 5504d94e36 cmake: update generation of 'uninstall' target
Details: https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#can-i-do-make-uninstall-with-cmake
2020-04-07 22:03:12 +00:00
Alexander Alekhin adf54d41d5 Merge pull request #16905 from dkurt:dnn_tf2_keras 2020-04-07 14:59:42 +00:00
mehlukas 75bd9f86b2 Merge pull request #16889 from mehlukas:3.4-consolidateImshow
* consolidate tutorials on image read/display/write

* fix unsused variables

* apply requested changes

* apply requested changes

* fix mistake
2020-04-07 14:14:51 +00:00
Liubov Batanina 734771418e Merge pull request #16840 from l-bat:matmul_inputs
* Supported FullyConnected layer with two inputs

* Skipped test

* Fix conditions

* Added OpenCL support

* Supported ReduceMean3D

* Supported Expand layer

* Fix warning

* Added Normalize subgraph

* refactoring

* Used addLayer

* Fix check

* Used addLayer

* Skip failed test

* Added normalize1 subgraph

* Fix comments
2020-04-07 14:12:18 +00:00
Alexander Alekhin 51a8885566 Merge pull request #16984 from CSharperMantle:argparse-patch-1 2020-04-07 12:54:27 +00:00
Alexander Alekhin 60c382d8f1 Merge pull request #17005 from tomoaki0705:fixHoughKernelLocal 2020-04-07 10:05:44 +00:00
Tomoaki Teshima 3371e679ce fix OpenCL spec violation 2020-04-07 14:34:55 +09:00
Alexander Alekhin ce5626db45 Merge pull request #16878 from dkurt:fix_16877 2020-04-06 18:14:35 +00:00
Alexander Alekhin 1377b9b736 Merge pull request #16970 from l-bat:fix_enet 2020-04-06 15:57:08 +00:00
Alexander Alekhin 936428cb3b core(MatExpr) fetch result before InputArray wrap
- avoid multiple expression evaluations
- avoid issues with reduced support of InputArray::EXPR
2020-04-06 15:28:32 +00:00
Alexander Alekhin c305455cb2 Merge pull request #16967 from benji1123:patch-1 2020-04-06 15:17:23 +00:00
Adam Fowles 8334932a26 Merge pull request #16992 from afowles:fix-forEach-segfault
* Fixed divide by zero error in forEach

* Dedicated assertion for !empty
2020-04-06 14:49:02 +00:00
Alexander Alekhin 99d29c9d39 Merge pull request #16982 from tomoaki0705:houghLinesOCL 2020-04-06 14:35:14 +00:00
Liubov Batanina a448d3a6aa Fix ENet test with OpenVINO 2020.2 2020-04-06 17:29:43 +03:00
Ben Li 1a6b4d6ce6 typo fix 2020-04-06 14:56:31 +03:00
Alexander Alekhin a15417fe74 Merge pull request #16980 from albert-github:feature/bug_doxyfile 2020-04-06 11:37:18 +00:00
Bao "Mantle" Rong 3dcb775d16 switch to argparse 2020-04-05 11:57:04 +08:00
albert-github 2d387356de Incorrect PREDEFINED setting.
The PREDEFINED setting for  had a space between the define name and the equal sign and this is not allowed, it results in the warning:
```
error: Illegal PREDEFINED format '=', no define name specified
```
according to the documentation explicitly states that no space is allowed:
> The PREDEFINED tag can be used to specify one or more macro names that are defined before the preprocessor is started (similar to the -D option of e.g. gcc). The argument of the tag is a list of macros of the form: name or name=definition (no spaces). If the definition and the "=" are omitted, "=1" is assumed. To prevent a macro definition from being undefined via #undef or recursively expanded use the := operator instead of the = operator.
2020-04-04 16:50:15 +00:00
Tomoaki Teshima 07c3aae315 let the test pass on Mali G52 (ODROID-N2) 2020-04-05 01:39:47 +09:00
Dmitry Kurtaev b36eba7fab Support FusedResizeAndPadConv2D from TensorFlow 2020-04-04 16:02:17 +03:00
Dmitry Kurtaev 8574a757f9 Case sensitive dnn layers types 2020-04-04 15:03:56 +03:00
Alexander Alekhin 0812207db7 Merge tag '3.4.10' 2020-04-03 11:24:31 +00:00
Alexander Alekhin 1cc1e6fa56 release: OpenCV 3.4.10 2020-04-02 19:59:58 +00:00
Alexander Alekhin 6216bf9221 Merge pull request #16959 from alalek:winpack_dldt_update 2020-04-02 18:13:58 +00:00
Alexander Alekhin 388a7ce86e Merge pull request #16956 from alalek:ocl_control_buffer_mapping 2020-04-02 17:56:50 +00:00
Alexander Alekhin 5d95a500ad winpack_dldt: readme update 2020-04-02 16:52:46 +00:00
Alexander Alekhin 95341c2b1b Merge pull request #16953 from mshabunin:fix-msmf-writer-fps 2020-04-02 13:06:34 +00:00
Alexander Alekhin 54063c40de core(ocl): options to control buffer access flags
- control using of clEnqueueMapBuffer or clEnqueueReadBuffer[Rect]
- added benchmarks with OpenCL buffer access use cases
2020-04-02 11:11:06 +00:00
Maksim Shabunin 585593e9fc videoio: fixed MSMF writer fps handling 2020-04-02 12:52:38 +03:00
Alexander Alekhin f15e885baf Merge pull request #16950 from alalek:fix_16945 2020-04-02 09:26:09 +00:00
Alexander Alekhin 9109cb1ec6 Merge pull request #16948 from alalek:warning_16739 2020-04-02 09:25:47 +00:00
Alexander Alekhin dc9ee53ff5 stitching: fix range check in DpSeamFinder::computeCosts 2020-04-02 03:51:17 +00:00
Alexander Alekhin 1485968fc4 Merge pull request #16947 from mshabunin:fix-msmf-convert-format 2020-04-01 18:50:12 +00:00
Alexander Alekhin 09134ac881 core: emit warning ONCE on ambiguous MatExpr processing 2020-04-01 18:34:20 +00:00
Maksim Shabunin 433c5199fd videoio: fixed conversion in MSMF backend 2020-04-01 14:40:11 +03:00
Alexander Alekhin 396f43d674 Merge pull request #16938 from alalek:winpack_samples_update 2020-04-01 01:46:13 +03:00
Alexander Alekhin e12b1c2209 build: updates for winpack dldt 2020-03-31 20:29:11 +00:00
Alexander Alekhin f6b2b49e4a Merge pull request #16932 from alalek:imgproc_resize_nn_cleanup 2020-03-30 15:38:40 +00:00
Alexander Alekhin e1322cf503 Merge pull request #16928 from alalek:fix_15075 2020-03-30 13:07:35 +00:00
Alexander Alekhin 67dfdee33f Merge pull request #16922 from alalek:imgcodecs_test_io_grayscale 2020-03-29 16:36:06 +00:00
Alexander Alekhin 61c4cfd896 imgproc(resize): drop unused 'pix_size4' 2020-03-29 02:41:50 +00:00
Alexander Alekhin be17f532e1 imgproc(resize): fix resizeNNInvoker handling of generic pixel size 2020-03-29 02:41:41 +00:00
Alexander Alekhin 6d85fa3fd2 imgcodecs(test): rework common I/O test, added grayscale mode 2020-03-27 21:34:51 +00:00
Alexander Alekhin 222a48577f Merge pull request #16919 from alalek:backport_16860 2020-03-27 16:44:05 +00:00
Alexander Alekhin 353273579b Merge pull request #16918 from alalek:build_warnings_3.4 2020-03-27 16:43:23 +00:00
Alexander Alekhin 7373ef0983 Merge pull request #16847 from alalek:build_opencv_winpack_dldt 2020-03-27 16:06:19 +00:00
Moritz Fischer-Gundlach 2740901378 -calib3d updates documentation
backporting commit 99436bb8cf
2020-03-27 16:02:29 +00:00
Alexander Alekhin e661ad2a67 eliminate build warnings 2020-03-27 11:39:07 +00:00
Alexander Alekhin 3a4b79173b Merge pull request #16916 from cyyever:fix_freebsd_build 2020-03-27 11:38:57 +00:00
cyy bdc29cccb6 fix freebsd build 2020-03-27 18:12:10 +08:00
Alexander Alekhin 7465125f67 build: add winpack_dldt build scripts 2020-03-25 21:26:41 +00:00
Alexander Alekhin 340df65fb4 Merge pull request #16903 from alalek:fix_16823_3.4 2020-03-25 15:53:08 +00:00
Alexander Alekhin 9a463b74dc Merge pull request #16901 from alalek:cmake_ie_find_extra_libs 2020-03-25 15:52:15 +00:00
Dmitry Kurtaev 7e4b2057f2 Import TF2.0 network from Keras 2020-03-25 15:34:28 +03:00
Alexander Alekhin c920b45fb8 core(persistence): fix resource leaks - force closing files
backporting commit 673eb2b006
2020-03-25 10:49:16 +00:00
Alexander Alekhin 2a9a2fff66 cmake: fix find process for InferenceEngine extra libraries 2020-03-25 02:43:42 +00:00
ab-dragon 2947877871 [move sift.cpp] Merge pull request opencv/opencv_contrib#2301 from ab-dragon:conditionally_compute_dog_pyramid
Build DoG Pyramid if useProvideKeypoints is false

The buildDoGPyramid operation need not be performed unconditionally. In cases where it is not needed, both memory and speed performance can be improved

original commit: https://github.com/opencv/opencv_contrib/commit/e45887e1c097db6e5f75dc70d7723203bcafa5f1
2019-11-01 21:28:18 +03:00
Alexander Alekhin fadb90c579 [move sift.cpp] xfeatures2d: use updated TLS API
original commit: https://github.com/opencv/opencv_contrib/commit/3e4fb8f415ba68c56ba2cded1ab10a75c46d342e
2019-10-20 14:17:05 +00:00
Alexander Alekhin fd46684bf8 [move sift.cpp] opencv: use cv::AutoBuffer<>::data()
original commit: https://github.com/opencv/opencv_contrib/commit/fc69aa57bc021422d825a4331f7ddf7d9f7534e7
2018-06-13 19:11:18 +00:00
Alexander Alekhin 9badb0d903 [move sift.cpp] xfeatures2d: apply CV_OVERRIDE/CV_FINAL
original commit: https://github.com/opencv/opencv_contrib/commit/ec65e5b29c1c4928aee3d56a44bb399d4af6b61a
2018-03-28 16:50:00 +03:00
Vitaly Tuzov c5f06814bc [move sift.cpp] Updated internal calls to linear resize to use bit-exact version
original commit: https://github.com/opencv/opencv_contrib/commit/8c394a4f2e02994f21c3cf88706ad62d65b53431
2017-12-14 13:00:09 +03:00
woody.chow 69d43e2997 [move sift.cpp] Remove unnecessary _mm256_round_ps
original commit: https://github.com/opencv/opencv_contrib/commit/b5340f6428b6d48445947b16ef2df04552451330
2017-09-26 10:12:30 +09:00
Woody Chow 0f0dea79fc [move sift.cpp] Use TLS instead of mutex in SIFT
original commit: https://github.com/opencv/opencv_contrib/commit/ab43a3b2d99c490be8635987923e7571fd95a0c9
2017-05-31 15:08:32 +09:00
Woody Chow b6d636214e [move sift.cpp] Multithreading findScaleSpaceExtremaComputer. Sort the keypoints afterwards to make the output stable
original commit: https://github.com/opencv/opencv_contrib/commit/6be2945abb0dcff2e038b5f23c7c7716da69ede9
2017-05-31 10:02:09 +09:00
Woody Chow 4b64955a12 [move sift.cpp] Parallelize calcDescriptors and buildDoGPyramid. Simplify 2 lines of AVX2 instructions
original commit: https://github.com/opencv/opencv_contrib/commit/443f68cb71128d5ae27e8771a91f7641f9450685
2017-03-24 16:31:18 +09:00
Woody Chow 546239a3a8 [move sift.cpp] Optimize SIFT with AVX2
original commit: https://github.com/opencv/opencv_contrib/commit/c5e55dfde96307fef12fc55f63d6a600fd784582
2017-03-08 10:08:50 +09:00
Suleyman TURKMEN 8be0a3452d [move sift.cpp] Update sift.cpp
original commit: https://github.com/opencv/opencv_contrib/commit/cb7b59f203bf06586d6176ac812e0ee382cedcf1
2016-12-23 13:21:30 +03:00
Martin Nowak 99d914ea3b [move sift.cpp] fix overflow issue when computing diagonal
- with big images the int multiplication can overflow

original commit: https://github.com/opencv/opencv_contrib/commit/d4df727d380887fdd880fdb5430cf4680a4ad19b
2016-06-11 17:51:46 +02:00
Maksim Shabunin 24284d3d17 [move sift.cpp] Fixed HAL headers location
original commit: https://github.com/opencv/opencv_contrib/commit/f529a1df2b17bcada1179ddcaf1352e3a5ba97b8
2015-12-15 18:41:26 +03:00
Vadim Pisarevsky 9fc872b70b [move sift.cpp] fixed contrib code to match the HAL
original commit: https://github.com/opencv/opencv_contrib/commit/cdddcc8237627f667d66daffb3fcb3af39a3e673
2015-04-16 22:52:05 +03:00
Vadim Pisarevsky e3654d5416 [move sift.cpp] refactored xfeatures2d in the same style as features2d
original commit: https://github.com/opencv/opencv_contrib/commit/0cfd795303c414aada6d10701e0de4995841210c
2014-10-16 16:33:21 +04:00
Alexander Alekhin d92bee821d Merge upstream branch 2020-04-21 06:20:05 +00:00
Alexander Alekhin df10411e05 features2d(sift): patent expiration note 2020-04-21 06:19:16 +00:00
Alexander Alekhin 44e9fb306d features2d(sift): code from nonfree module 2020-04-21 04:14:18 +00:00
612 changed files with 20837 additions and 5831 deletions
+2 -1
View File
@@ -40,4 +40,5 @@ if(WITH_NEON)
target_compile_definitions(carotene_objs PRIVATE "-DWITH_NEON")
endif()
add_library(carotene STATIC EXCLUDE_FROM_ALL "$<TARGET_OBJECTS:carotene_objs>")
# we add dummy file to fix XCode build
add_library(carotene STATIC EXCLUDE_FROM_ALL "$<TARGET_OBJECTS:carotene_objs>" "${CAROTENE_SOURCE_DIR}/dummy.cpp")
+2 -1
View File
@@ -80,7 +80,8 @@ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${carotene_defs})
# set_source_files_properties(impl.cpp $<TARGET_OBJECTS:carotene_objs> COMPILE_FLAGS "--param ipcp-unit-growth=100000 --param inline-unit-growth=100000 --param large-stack-frame-growth=5000")
endif()
add_library(tegra_hal STATIC $<TARGET_OBJECTS:carotene_objs>)
# we add dummy file to fix XCode build
add_library(tegra_hal STATIC $<TARGET_OBJECTS:carotene_objs> "dummy.cpp")
set_target_properties(tegra_hal PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH})
set(OPENCV_SRC_DIR "${CMAKE_SOURCE_DIR}")
if(NOT BUILD_SHARED_LIBS)
+2
View File
@@ -0,0 +1,2 @@
// This file is needed for compilation on some platforms e.g. with XCode generator
// Related issue: https://gitlab.kitware.com/cmake/cmake/-/issues/17457
+2
View File
@@ -0,0 +1,2 @@
// This file is needed for compilation on some platforms e.g. with XCode generator
// Related issue: https://gitlab.kitware.com/cmake/cmake/-/issues/17457
+5 -5
View File
@@ -1,8 +1,8 @@
# Binaries branch name: ffmpeg/3.4_20200310
# Binaries were created for OpenCV: 4966186e10e2a940514d8c20447ca4a828af5f46
ocv_update(FFMPEG_BINARIES_COMMIT "e81ccda615672833b578c6cefdb859ad69c560ba")
ocv_update(FFMPEG_FILE_HASH_BIN32 "301ae2000e25f800ab8e0065f277ad28")
ocv_update(FFMPEG_FILE_HASH_BIN64 "d87ce032289c3f811d02f0c3d8dbe366")
# Binaries branch name: ffmpeg/3.4_20200907
# Binaries were created for OpenCV: 03bee14372f5537daa56c62e771ec16181ca1f98
ocv_update(FFMPEG_BINARIES_COMMIT "2a96257b743695a47f8012aab1ffb995a1dee8b4")
ocv_update(FFMPEG_FILE_HASH_BIN32 "5e68a3ff82f43ac6524e50e448a34c9c")
ocv_update(FFMPEG_FILE_HASH_BIN64 "205db629d893e7d4865fd1459807ff47")
ocv_update(FFMPEG_FILE_HASH_CMAKE "3b90f67f4b429e77d3da36698cef700c")
function(download_win_ffmpeg script_var)
+4 -2
View File
@@ -4,9 +4,9 @@ ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter -Wsign-compare -Wshorten-6
set(VERSION_MAJOR 2)
set(VERSION_MINOR 0)
set(VERSION_REVISION 4)
set(VERSION_REVISION 5)
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION})
set(LIBJPEG_TURBO_VERSION_NUMBER 2000004)
set(LIBJPEG_TURBO_VERSION_NUMBER 2000005)
string(TIMESTAMP BUILD "opencv-${OPENCV_VERSION}-libjpeg-turbo")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
@@ -65,6 +65,8 @@ set(JPEG_LIB_VERSION 62)
# OpenCV
set(JPEG_LIB_VERSION "${VERSION}-${JPEG_LIB_VERSION}" PARENT_SCOPE)
set(THREAD_LOCAL "") # WITH_TURBOJPEG is not used
if(MSVC)
add_definitions(-W3 -wd4996 -wd4018)
endif()
+3
View File
@@ -15,6 +15,9 @@
#endif
#endif
/* How to obtain thread-local storage */
#define THREAD_LOCAL @THREAD_LOCAL@
/* Define to the full name of this package. */
#define PACKAGE_NAME "@CMAKE_PROJECT_NAME@"
+1 -2
View File
@@ -143,8 +143,7 @@ empty_mem_output_buffer(j_compress_ptr cinfo)
MEMCOPY(nextbuffer, dest->buffer, dest->bufsize);
if (dest->newbuffer != NULL)
free(dest->newbuffer);
free(dest->newbuffer);
dest->newbuffer = nextbuffer;
+3 -3
View File
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-2012, Thomas G. Lane, Guido Vollbeding.
* libjpeg-turbo Modifications:
* Copyright (C) 2010, 2012-2019, D. R. Commander.
* Copyright (C) 2010, 2012-2020, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -36,7 +36,7 @@
*/
#define JCOPYRIGHT \
"Copyright (C) 2009-2019 D. R. Commander\n" \
"Copyright (C) 2009-2020 D. R. Commander\n" \
"Copyright (C) 2011-2016 Siarhei Siamashka\n" \
"Copyright (C) 2015-2016, 2018 Matthieu Darbois\n" \
"Copyright (C) 2015 Intel Corporation\n" \
@@ -49,4 +49,4 @@
"Copyright (C) 1991-2016 Thomas G. Lane, Guido Vollbeding"
#define JCOPYRIGHT_SHORT \
"Copyright (C) 1991-2019 The libjpeg-turbo Project and many others"
"Copyright (C) 1991-2020 The libjpeg-turbo Project and many others"
+6 -13
View File
@@ -1,7 +1,7 @@
The Independent JPEG Group's JPEG software
==========================================
README for release 9c of 14-Jan-2018
README for release 9d of 12-Jan-2020
====================================
This distribution contains the ninth public release of the Independent JPEG
@@ -10,8 +10,8 @@ to use it for any purpose, subject to the conditions under LEGAL ISSUES, below.
This software is the work of Tom Lane, Guido Vollbeding, Philip Gladstone,
Bill Allombert, Jim Boucher, Lee Crocker, Bob Friesenhahn, Ben Jackson,
Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi, Ge' Weijers,
and other members of the Independent JPEG Group.
John Korejwa, Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi,
Ge' Weijers, and other members of the Independent JPEG Group.
IJG is not affiliated with the ISO/IEC JTC1/SC29/WG1 standards committee
(previously known as JPEG, together with ITU-T SG16).
@@ -115,7 +115,7 @@ with respect to this software, its quality, accuracy, merchantability, or
fitness for a particular purpose. This software is provided "AS IS", and you,
its user, assume the entire risk as to its quality and accuracy.
This software is copyright (C) 1991-2018, Thomas G. Lane, Guido Vollbeding.
This software is copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
All Rights Reserved except as specified below.
Permission is hereby granted to use, copy, modify, and distribute this
@@ -152,13 +152,6 @@ The same holds for its supporting scripts (config.guess, config.sub,
ltmain.sh). Another support script, install-sh, is copyright by X Consortium
but is also freely distributable.
The IJG distribution formerly included code to read and write GIF files.
To avoid entanglement with the Unisys LZW patent (now expired), GIF reading
support has been removed altogether, and the GIF writer has been simplified
to produce "uncompressed GIFs". This technique does not use the LZW
algorithm; the resulting GIF files are larger than usual, but are readable
by all standard GIF decoders.
REFERENCES
==========
@@ -246,8 +239,8 @@ ARCHIVE LOCATIONS
The "official" archive site for this software is www.ijg.org.
The most recent released version can always be found there in
directory "files". This particular version will be archived as
http://www.ijg.org/files/jpegsrc.v9c.tar.gz, and in Windows-compatible
"zip" archive format as http://www.ijg.org/files/jpegsr9c.zip.
http://www.ijg.org/files/jpegsrc.v9d.tar.gz, and in Windows-compatible
"zip" archive format as http://www.ijg.org/files/jpegsr9d.zip.
The JPEG FAQ (Frequently Asked Questions) article is a source of some
general information about JPEG.
+49
View File
@@ -1,6 +1,55 @@
CHANGE LOG for Independent JPEG Group's JPEG software
Version 9d 12-Jan-2020
-----------------------
Optimize the optimal Huffman code table generation to produce
slightly smaller files. Thank to John Korejwa for suggestion.
Note: Requires rebuild of testimgp.jpg.
Decoding Huffman: Use default tables if tables are not defined.
Thank to Simone Azzalin for report (Motion JPEG),
and to Martin Strunz for hint.
Add sanity check in optimal Huffman code table generation.
Thank to Adam Farley for suggestion.
rdtarga.c: use read_byte(), with EOF check, instead of getc()
in read_*_pixel().
Thank to Chijin Zhou for cjpeg potential vulnerability report.
jmemnobs.c: respect the max_memory_to_use setting in
jpeg_mem_available() computation. Thank to Sheng Shu and
Dongdong She for djpeg potential vulnerability report.
jdarith.c, jdhuff.c: avoid left shift of negative value
compiler warning in decode_mcu_AC_refine().
Thank to Indu Bhagat for suggestion.
Add x64 (64-bit) platform support, avoid compiler warnings.
Thank to Jonathan Potter, Feiyun Wang, and Sheng Shu for suggestion.
Adjust libjpeg version specification for pkg-config file.
Thank to Chen Chen for suggestion.
Restore GIF read and write support from libjpeg version 6a.
Thank to Wolfgang Werner (W.W.) Heinz for suggestion.
Improve consistency in raw (downsampled) image data processing mode.
Thank to Zhongyuan Zhou for hint.
Avoid out of bounds array read (AC derived table pointers)
in start pass in jdhuff.c. Thank to Peng Li for report.
Improve code sanity (jdhuff.c).
Thank to Reza Mirzazade farkhani for reports.
Add jpegtran -drop option; add options to the crop extension and wipe
to fill the extra area with content from the source image region,
instead of gray out.
Version 9c 14-Jan-2018
-----------------------
+9 -8
View File
@@ -1,7 +1,7 @@
/*
* jcarith.c
*
* Developed 1997-2013 by Guido Vollbeding.
* Developed 1997-2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -181,11 +181,11 @@ finish_pass (j_compress_ptr cinfo)
if (e->zc) /* output final pending zero bytes */
do emit_byte(0x00, cinfo);
while (--e->zc);
emit_byte((e->c >> 19) & 0xFF, cinfo);
emit_byte((int) ((e->c >> 19) & 0xFF), cinfo);
if (((e->c >> 19) & 0xFF) == 0xFF)
emit_byte(0x00, cinfo);
if (e->c & 0x7F800L) {
emit_byte((e->c >> 11) & 0xFF, cinfo);
emit_byte((int) ((e->c >> 11) & 0xFF), cinfo);
if (((e->c >> 11) & 0xFF) == 0xFF)
emit_byte(0x00, cinfo);
}
@@ -280,7 +280,8 @@ arith_encode (j_compress_ptr cinfo, unsigned char *st, int val)
/* Note: The 3 spacer bits in the C register guarantee
* that the new buffer byte can't be 0xFF here
* (see page 160 in the P&M JPEG book). */
e->buffer = temp & 0xFF; /* new output byte, might overflow later */
/* New output byte, might overflow later */
e->buffer = (int) (temp & 0xFF);
} else if (temp == 0xFF) {
++e->sc; /* stack 0xFF byte (which might overflow later) */
} else {
@@ -302,7 +303,8 @@ arith_encode (j_compress_ptr cinfo, unsigned char *st, int val)
emit_byte(0x00, cinfo);
} while (--e->sc);
}
e->buffer = temp & 0xFF; /* new output byte (can still overflow) */
/* New output byte (can still overflow) */
e->buffer = (int) (temp & 0xFF);
}
e->c &= 0x7FFFFL;
e->ct += 8;
@@ -926,9 +928,8 @@ jinit_arith_encoder (j_compress_ptr cinfo)
arith_entropy_ptr entropy;
int i;
entropy = (arith_entropy_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(arith_entropy_encoder));
entropy = (arith_entropy_ptr) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(arith_entropy_encoder));
cinfo->entropy = &entropy->pub;
entropy->pub.start_pass = start_pass;
entropy->pub.finish_pass = finish_pass;
+47 -50
View File
@@ -2,7 +2,7 @@
* jccolor.c
*
* Copyright (C) 1991-1996, Thomas G. Lane.
* Modified 2011-2013 by Guido Vollbeding.
* Modified 2011-2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -105,14 +105,14 @@ rgb_ycc_start (j_compress_ptr cinfo)
/* Allocate and fill in the conversion tables. */
cconvert->rgb_ycc_tab = rgb_ycc_tab = (INT32 *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(TABLE_SIZE * SIZEOF(INT32)));
TABLE_SIZE * SIZEOF(INT32));
for (i = 0; i <= MAXJSAMPLE; i++) {
rgb_ycc_tab[i+R_Y_OFF] = FIX(0.299) * i;
rgb_ycc_tab[i+G_Y_OFF] = FIX(0.587) * i;
rgb_ycc_tab[i+B_Y_OFF] = FIX(0.114) * i + ONE_HALF;
rgb_ycc_tab[i+R_CB_OFF] = (-FIX(0.168735892)) * i;
rgb_ycc_tab[i+G_CB_OFF] = (-FIX(0.331264108)) * i;
rgb_ycc_tab[i+R_CB_OFF] = (- FIX(0.168735892)) * i;
rgb_ycc_tab[i+G_CB_OFF] = (- FIX(0.331264108)) * i;
/* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr.
* This ensures that the maximum output will round to MAXJSAMPLE
* not MAXJSAMPLE+1, and thus that we don't have to range-limit.
@@ -121,8 +121,8 @@ rgb_ycc_start (j_compress_ptr cinfo)
/* B=>Cb and R=>Cr tables are the same
rgb_ycc_tab[i+R_CR_OFF] = FIX(0.5) * i + CBCR_OFFSET + ONE_HALF-1;
*/
rgb_ycc_tab[i+G_CR_OFF] = (-FIX(0.418687589)) * i;
rgb_ycc_tab[i+B_CR_OFF] = (-FIX(0.081312411)) * i;
rgb_ycc_tab[i+G_CR_OFF] = (- FIX(0.418687589)) * i;
rgb_ycc_tab[i+B_CR_OFF] = (- FIX(0.081312411)) * i;
}
}
@@ -131,12 +131,12 @@ rgb_ycc_start (j_compress_ptr cinfo)
* Convert some rows of samples to the JPEG colorspace.
*
* Note that we change from the application's interleaved-pixel format
* to our internal noninterleaved, one-plane-per-component format.
* The input buffer is therefore three times as wide as the output buffer.
* to our internal noninterleaved, one-plane-per-component format. The
* input buffer is therefore three times as wide as the output buffer.
*
* A starting row offset is provided only for the output buffer. The caller
* can easily adjust the passed input_buf value to accommodate any row
* offset required on that side.
* A starting row offset is provided only for the output buffer. The
* caller can easily adjust the passed input_buf value to accommodate
* any row offset required on that side.
*/
METHODDEF(void)
@@ -145,8 +145,8 @@ rgb_ycc_convert (j_compress_ptr cinfo,
JDIMENSION output_row, int num_rows)
{
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
register INT32 * ctab = cconvert->rgb_ycc_tab;
register int r, g, b;
register INT32 * ctab = cconvert->rgb_ycc_tab;
register JSAMPROW inptr;
register JSAMPROW outptr0, outptr1, outptr2;
register JDIMENSION col;
@@ -162,6 +162,7 @@ rgb_ycc_convert (j_compress_ptr cinfo,
r = GETJSAMPLE(inptr[RGB_RED]);
g = GETJSAMPLE(inptr[RGB_GREEN]);
b = GETJSAMPLE(inptr[RGB_BLUE]);
inptr += RGB_PIXELSIZE;
/* If the inputs are 0..MAXJSAMPLE, the outputs of these equations
* must be too; we do not need an explicit range-limiting operation.
* Hence the value being shifted is never negative, and we don't
@@ -179,7 +180,6 @@ rgb_ycc_convert (j_compress_ptr cinfo,
outptr2[col] = (JSAMPLE)
((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF])
>> SCALEBITS);
inptr += RGB_PIXELSIZE;
}
}
}
@@ -201,8 +201,8 @@ rgb_gray_convert (j_compress_ptr cinfo,
JDIMENSION output_row, int num_rows)
{
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
register INT32 * ctab = cconvert->rgb_ycc_tab;
register int r, g, b;
register INT32 * ctab = cconvert->rgb_ycc_tab;
register JSAMPROW inptr;
register JSAMPROW outptr;
register JDIMENSION col;
@@ -215,11 +215,11 @@ rgb_gray_convert (j_compress_ptr cinfo,
r = GETJSAMPLE(inptr[RGB_RED]);
g = GETJSAMPLE(inptr[RGB_GREEN]);
b = GETJSAMPLE(inptr[RGB_BLUE]);
inptr += RGB_PIXELSIZE;
/* Y */
outptr[col] = (JSAMPLE)
((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF])
>> SCALEBITS);
inptr += RGB_PIXELSIZE;
}
}
}
@@ -228,8 +228,8 @@ rgb_gray_convert (j_compress_ptr cinfo,
/*
* Convert some rows of samples to the JPEG colorspace.
* This version handles Adobe-style CMYK->YCCK conversion,
* where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the same
* conversion as above, while passing K (black) unchanged.
* where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the
* same conversion as above, while passing K (black) unchanged.
* We assume rgb_ycc_start has been called.
*/
@@ -239,8 +239,8 @@ cmyk_ycck_convert (j_compress_ptr cinfo,
JDIMENSION output_row, int num_rows)
{
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
register INT32 * ctab = cconvert->rgb_ycc_tab;
register int r, g, b;
register INT32 * ctab = cconvert->rgb_ycc_tab;
register JSAMPROW inptr;
register JSAMPROW outptr0, outptr1, outptr2, outptr3;
register JDIMENSION col;
@@ -259,6 +259,7 @@ cmyk_ycck_convert (j_compress_ptr cinfo,
b = MAXJSAMPLE - GETJSAMPLE(inptr[2]);
/* K passes through as-is */
outptr3[col] = inptr[3]; /* don't need GETJSAMPLE here */
inptr += 4;
/* If the inputs are 0..MAXJSAMPLE, the outputs of these equations
* must be too; we do not need an explicit range-limiting operation.
* Hence the value being shifted is never negative, and we don't
@@ -276,7 +277,6 @@ cmyk_ycck_convert (j_compress_ptr cinfo,
outptr2[col] = (JSAMPLE)
((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF])
>> SCALEBITS);
inptr += 4;
}
}
}
@@ -312,13 +312,13 @@ rgb_rgb1_convert (j_compress_ptr cinfo,
r = GETJSAMPLE(inptr[RGB_RED]);
g = GETJSAMPLE(inptr[RGB_GREEN]);
b = GETJSAMPLE(inptr[RGB_BLUE]);
inptr += RGB_PIXELSIZE;
/* Assume that MAXJSAMPLE+1 is a power of 2, so that the MOD
* (modulo) operator is equivalent to the bitmask operator AND.
*/
outptr0[col] = (JSAMPLE) ((r - g + CENTERJSAMPLE) & MAXJSAMPLE);
outptr1[col] = (JSAMPLE) g;
outptr2[col] = (JSAMPLE) ((b - g + CENTERJSAMPLE) & MAXJSAMPLE);
inptr += RGB_PIXELSIZE;
}
}
}
@@ -335,17 +335,17 @@ grayscale_convert (j_compress_ptr cinfo,
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
JDIMENSION output_row, int num_rows)
{
int instride = cinfo->input_components;
register JSAMPROW inptr;
register JSAMPROW outptr;
register JDIMENSION col;
register JDIMENSION count;
register int instride = cinfo->input_components;
JDIMENSION num_cols = cinfo->image_width;
while (--num_rows >= 0) {
inptr = *input_buf++;
outptr = output_buf[0][output_row++];
for (col = 0; col < num_cols; col++) {
outptr[col] = inptr[0]; /* don't need GETJSAMPLE() here */
for (count = num_cols; count > 0; count--) {
*outptr++ = *inptr; /* don't need GETJSAMPLE() here */
inptr += instride;
}
}
@@ -396,21 +396,21 @@ null_convert (j_compress_ptr cinfo,
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
JDIMENSION output_row, int num_rows)
{
int ci;
register int nc = cinfo->num_components;
register JSAMPROW inptr;
register JSAMPROW outptr;
register JDIMENSION col;
register JDIMENSION count;
register int num_comps = cinfo->num_components;
JDIMENSION num_cols = cinfo->image_width;
int ci;
while (--num_rows >= 0) {
/* It seems fastest to make a separate pass for each component. */
for (ci = 0; ci < nc; ci++) {
for (ci = 0; ci < num_comps; ci++) {
inptr = input_buf[0] + ci;
outptr = output_buf[ci][output_row];
for (col = 0; col < num_cols; col++) {
for (count = num_cols; count > 0; count--) {
*outptr++ = *inptr; /* don't need GETJSAMPLE() here */
inptr += nc;
inptr += num_comps;
}
}
input_buf++;
@@ -439,9 +439,8 @@ jinit_color_converter (j_compress_ptr cinfo)
{
my_cconvert_ptr cconvert;
cconvert = (my_cconvert_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_color_converter));
cconvert = (my_cconvert_ptr) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_color_converter));
cinfo->cconvert = &cconvert->pub;
/* set start_pass to null method until we find out differently */
cconvert->pub.start_pass = null_method;
@@ -455,9 +454,11 @@ jinit_color_converter (j_compress_ptr cinfo)
case JCS_RGB:
case JCS_BG_RGB:
#if RGB_PIXELSIZE != 3
if (cinfo->input_components != RGB_PIXELSIZE)
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
break;
#endif /* else share code with YCbCr */
case JCS_YCbCr:
case JCS_BG_YCC:
@@ -474,7 +475,6 @@ jinit_color_converter (j_compress_ptr cinfo)
default: /* JCS_UNKNOWN can be anything */
if (cinfo->input_components < 1)
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
break;
}
/* Support color transform only for RGB colorspaces */
@@ -507,19 +507,18 @@ jinit_color_converter (j_compress_ptr cinfo)
case JCS_BG_RGB:
if (cinfo->num_components != 3)
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
if (cinfo->in_color_space == cinfo->jpeg_color_space) {
switch (cinfo->color_transform) {
case JCT_NONE:
cconvert->pub.color_convert = rgb_convert;
break;
case JCT_SUBTRACT_GREEN:
cconvert->pub.color_convert = rgb_rgb1_convert;
break;
default:
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
}
} else
if (cinfo->in_color_space != cinfo->jpeg_color_space)
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
switch (cinfo->color_transform) {
case JCT_NONE:
cconvert->pub.color_convert = rgb_convert;
break;
case JCT_SUBTRACT_GREEN:
cconvert->pub.color_convert = rgb_rgb1_convert;
break;
default:
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
}
break;
case JCS_YCbCr:
@@ -572,10 +571,9 @@ jinit_color_converter (j_compress_ptr cinfo)
case JCS_CMYK:
if (cinfo->num_components != 4)
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
if (cinfo->in_color_space == JCS_CMYK)
cconvert->pub.color_convert = null_convert;
else
if (cinfo->in_color_space != JCS_CMYK)
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
cconvert->pub.color_convert = null_convert;
break;
case JCS_YCCK:
@@ -599,6 +597,5 @@ jinit_color_converter (j_compress_ptr cinfo)
cinfo->num_components != cinfo->input_components)
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
cconvert->pub.color_convert = null_convert;
break;
}
}
+109 -42
View File
@@ -2,7 +2,7 @@
* jchuff.c
*
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2006-2013 by Guido Vollbeding.
* Modified 2006-2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -178,13 +178,12 @@ jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno,
htbl =
isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno];
if (htbl == NULL)
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
htbl = jpeg_std_huff_table((j_common_ptr) cinfo, isDC, tblno);
/* Allocate a workspace if we haven't already done so. */
if (*pdtbl == NULL)
*pdtbl = (c_derived_tbl *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(c_derived_tbl));
*pdtbl = (c_derived_tbl *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(c_derived_tbl));
dtbl = *pdtbl;
/* Figure C.1: make table of Huffman code length for each symbol */
@@ -1256,22 +1255,88 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
UINT8 bits[MAX_CLEN+1]; /* bits[k] = # of symbols with code length k */
int codesize[257]; /* codesize[k] = code length of symbol k */
int others[257]; /* next symbol in current branch of tree */
int c1, c2;
int p, i, j;
int c1, c2, i, j;
UINT8 *p;
long v;
freq[256] = 1; /* make sure 256 has a nonzero count */
/* Including the pseudo-symbol 256 in the Huffman procedure guarantees
* that no real symbol is given code-value of all ones, because 256
* will be placed last in the largest codeword category.
* In the symbol list build procedure this element serves as sentinel
* for the zero run loop.
*/
#ifndef DONT_USE_FANCY_HUFF_OPT
/* Build list of symbols sorted in order of descending frequency */
/* This approach has several benefits (thank to John Korejwa for the idea):
* 1.
* If a codelength category is split during the length limiting procedure
* below, the feature that more frequent symbols are assigned shorter
* codewords remains valid for the adjusted code.
* 2.
* To reduce consecutive ones in a Huffman data stream (thus reducing the
* number of stuff bytes in JPEG) it is preferable to follow 0 branches
* (and avoid 1 branches) as much as possible. This is easily done by
* assigning symbols to leaves of the Huffman tree in order of decreasing
* frequency, with no secondary sort based on codelengths.
* 3.
* The symbol list can be built independently from the assignment of code
* lengths by the Huffman procedure below.
* Note: The symbol list build procedure must be performed first, because
* the Huffman procedure assigning the codelengths clobbers the frequency
* counts!
*/
/* Here we use the others array as a linked list of nonzero frequencies
* to be sorted. Already sorted elements are removed from the list.
*/
/* Building list */
/* This item does not correspond to a valid symbol frequency and is used
* as starting index.
*/
j = 256;
for (i = 0;; i++) {
if (freq[i] == 0) /* skip zero frequencies */
continue;
if (i > 255)
break;
others[j] = i; /* this symbol value */
j = i; /* previous symbol value */
}
others[j] = -1; /* mark end of list */
/* Sorting list */
p = htbl->huffval;
while ((c1 = others[256]) >= 0) {
v = freq[c1];
i = c1; /* first symbol value */
j = 256; /* pseudo symbol value for starting index */
while ((c2 = others[c1]) >= 0) {
if (freq[c2] > v) {
v = freq[c2];
i = c2; /* this symbol value */
j = c1; /* previous symbol value */
}
c1 = c2;
}
others[j] = others[i]; /* remove this symbol i from list */
*p++ = (UINT8) i;
}
#endif /* DONT_USE_FANCY_HUFF_OPT */
/* This algorithm is explained in section K.2 of the JPEG standard */
MEMZERO(bits, SIZEOF(bits));
MEMZERO(codesize, SIZEOF(codesize));
for (i = 0; i < 257; i++)
others[i] = -1; /* init links to empty */
freq[256] = 1; /* make sure 256 has a nonzero count */
/* Including the pseudo-symbol 256 in the Huffman procedure guarantees
* that no real symbol is given code-value of all ones, because 256
* will be placed last in the largest codeword category.
*/
/* Huffman's basic algorithm to assign optimal code lengths to symbols */
@@ -1301,7 +1366,7 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
/* Done if we've merged everything into one frequency */
if (c2 < 0)
break;
/* Else merge the two counts/trees */
freq[c1] += freq[c2];
freq[c2] = 0;
@@ -1312,9 +1377,9 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
c1 = others[c1];
codesize[c1]++;
}
others[c1] = c2; /* chain c2 onto c1's tree branch */
/* Increment the codesize of everything in c2's tree branch */
codesize[c2]++;
while (others[c2] >= 0) {
@@ -1329,7 +1394,7 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
/* The JPEG standard seems to think that this can't happen, */
/* but I'm paranoid... */
if (codesize[i] > MAX_CLEN)
ERREXIT(cinfo, JERR_HUFF_CLEN_OVERFLOW);
ERREXIT(cinfo, JERR_HUFF_CLEN_OUTOFBOUNDS);
bits[codesize[i]]++;
}
@@ -1345,13 +1410,16 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
* shortest nonzero BITS entry is converted into a prefix for two code words
* one bit longer.
*/
for (i = MAX_CLEN; i > 16; i--) {
while (bits[i] > 0) {
j = i - 2; /* find length of new prefix to be used */
while (bits[j] == 0)
while (bits[j] == 0) {
if (j == 0)
ERREXIT(cinfo, JERR_HUFF_CLEN_OUTOFBOUNDS);
j--;
}
bits[i] -= 2; /* remove two symbols */
bits[i-1]++; /* one goes in this length */
bits[j+1] += 2; /* two new symbols in this length */
@@ -1363,24 +1431,27 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
while (bits[i] == 0) /* find largest codelength still in use */
i--;
bits[i]--;
/* Return final symbol counts (only for lengths 0..16) */
MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits));
#ifdef DONT_USE_FANCY_HUFF_OPT
/* Return a list of the symbols sorted by code length */
/* It's not real clear to me why we don't need to consider the codelength
* changes made above, but the JPEG spec seems to think this works.
/* Note: Due to the codelength changes made above, it can happen
* that more frequent symbols are assigned longer codewords.
*/
p = 0;
p = htbl->huffval;
for (i = 1; i <= MAX_CLEN; i++) {
for (j = 0; j <= 255; j++) {
if (codesize[j] == i) {
htbl->huffval[p] = (UINT8) j;
p++;
*p++ = (UINT8) j;
}
}
}
#endif /* DONT_USE_FANCY_HUFF_OPT */
/* Set sent_table FALSE so updated table will be written to JPEG file. */
htbl->sent_table = FALSE;
}
@@ -1400,13 +1471,13 @@ finish_pass_gather (j_compress_ptr cinfo)
boolean did_dc[NUM_HUFF_TBLS];
boolean did_ac[NUM_HUFF_TBLS];
/* It's important not to apply jpeg_gen_optimal_table more than once
* per table, because it clobbers the input frequency counts!
*/
if (cinfo->progressive_mode)
/* Flush out buffered data (all we care about is counting the EOB symbol) */
emit_eobrun(entropy);
/* It's important not to apply jpeg_gen_optimal_table more than once
* per table, because it clobbers the input frequency counts!
*/
MEMZERO(did_dc, SIZEOF(did_dc));
MEMZERO(did_ac, SIZEOF(did_ac));
@@ -1475,9 +1546,8 @@ start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics)
entropy->pub.encode_mcu = encode_mcu_AC_refine;
/* AC refinement needs a correction bit buffer */
if (entropy->bit_buffer == NULL)
entropy->bit_buffer = (char *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
MAX_CORR_BITS * SIZEOF(char));
entropy->bit_buffer = (char *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, MAX_CORR_BITS * SIZEOF(char));
}
}
@@ -1505,9 +1575,8 @@ start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics)
/* Allocate and zero the statistics tables */
/* Note that jpeg_gen_optimal_table expects 257 entries in each table! */
if (entropy->dc_count_ptrs[tbl] == NULL)
entropy->dc_count_ptrs[tbl] = (long *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
257 * SIZEOF(long));
entropy->dc_count_ptrs[tbl] = (long *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, 257 * SIZEOF(long));
MEMZERO(entropy->dc_count_ptrs[tbl], 257 * SIZEOF(long));
} else {
/* Compute derived values for Huffman tables */
@@ -1525,9 +1594,8 @@ start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics)
if (tbl < 0 || tbl >= NUM_HUFF_TBLS)
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl);
if (entropy->ac_count_ptrs[tbl] == NULL)
entropy->ac_count_ptrs[tbl] = (long *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
257 * SIZEOF(long));
entropy->ac_count_ptrs[tbl] = (long *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, 257 * SIZEOF(long));
MEMZERO(entropy->ac_count_ptrs[tbl], 257 * SIZEOF(long));
} else {
jpeg_make_c_derived_tbl(cinfo, FALSE, tbl,
@@ -1556,9 +1624,8 @@ jinit_huff_encoder (j_compress_ptr cinfo)
huff_entropy_ptr entropy;
int i;
entropy = (huff_entropy_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(huff_entropy_encoder));
entropy = (huff_entropy_ptr) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(huff_entropy_encoder));
cinfo->entropy = &entropy->pub;
entropy->pub.start_pass = start_pass_huff;
+3 -5
View File
@@ -2,7 +2,7 @@
* jcmarker.c
*
* Copyright (C) 1991-1998, Thomas G. Lane.
* Modified 2003-2013 by Guido Vollbeding.
* Modified 2003-2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -471,7 +471,6 @@ emit_adobe_app14 (j_compress_ptr cinfo)
break;
default:
emit_byte(cinfo, 0); /* Color transform = 0 */
break;
}
}
@@ -702,9 +701,8 @@ jinit_marker_writer (j_compress_ptr cinfo)
my_marker_ptr marker;
/* Create the subobject */
marker = (my_marker_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_marker_writer));
marker = (my_marker_ptr) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_marker_writer));
cinfo->marker = &marker->pub;
/* Initialize method pointers */
marker->pub.write_file_header = write_file_header;
+18 -15
View File
@@ -2,7 +2,7 @@
* jcmaster.c
*
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2003-2017 by Guido Vollbeding.
* Modified 2003-2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -62,7 +62,7 @@ initial_setup (j_compress_ptr cinfo)
case 5: cinfo->natural_order = jpeg_natural_order5; break;
case 6: cinfo->natural_order = jpeg_natural_order6; break;
case 7: cinfo->natural_order = jpeg_natural_order7; break;
default: cinfo->natural_order = jpeg_natural_order; break;
default: cinfo->natural_order = jpeg_natural_order;
}
/* Derive lim_Se from block_size */
@@ -114,20 +114,24 @@ initial_setup (j_compress_ptr cinfo)
*/
ssize = 1;
#ifdef DCT_SCALING_SUPPORTED
while (cinfo->min_DCT_h_scaled_size * ssize <=
(cinfo->do_fancy_downsampling ? DCTSIZE : DCTSIZE / 2) &&
(cinfo->max_h_samp_factor % (compptr->h_samp_factor * ssize * 2)) == 0) {
ssize = ssize * 2;
}
if (! cinfo->raw_data_in)
while (cinfo->min_DCT_h_scaled_size * ssize <=
(cinfo->do_fancy_downsampling ? DCTSIZE : DCTSIZE / 2) &&
(cinfo->max_h_samp_factor % (compptr->h_samp_factor * ssize * 2)) ==
0) {
ssize = ssize * 2;
}
#endif
compptr->DCT_h_scaled_size = cinfo->min_DCT_h_scaled_size * ssize;
ssize = 1;
#ifdef DCT_SCALING_SUPPORTED
while (cinfo->min_DCT_v_scaled_size * ssize <=
(cinfo->do_fancy_downsampling ? DCTSIZE : DCTSIZE / 2) &&
(cinfo->max_v_samp_factor % (compptr->v_samp_factor * ssize * 2)) == 0) {
ssize = ssize * 2;
}
if (! cinfo->raw_data_in)
while (cinfo->min_DCT_v_scaled_size * ssize <=
(cinfo->do_fancy_downsampling ? DCTSIZE : DCTSIZE / 2) &&
(cinfo->max_v_samp_factor % (compptr->v_samp_factor * ssize * 2)) ==
0) {
ssize = ssize * 2;
}
#endif
compptr->DCT_v_scaled_size = cinfo->min_DCT_v_scaled_size * ssize;
@@ -620,9 +624,8 @@ jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)
{
my_master_ptr master;
master = (my_master_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_comp_master));
master = (my_master_ptr) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_comp_master));
cinfo->master = &master->pub;
master->pub.prepare_for_pass = prepare_for_pass;
master->pub.pass_startup = pass_startup;
+138
View File
@@ -2,6 +2,7 @@
* jcomapi.c
*
* Copyright (C) 1994-1997, Thomas G. Lane.
* Modified 2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -104,3 +105,140 @@ jpeg_alloc_huff_table (j_common_ptr cinfo)
tbl->sent_table = FALSE; /* make sure this is false in any new table */
return tbl;
}
/*
* Set up the standard Huffman tables (cf. JPEG standard section K.3).
* IMPORTANT: these are only valid for 8-bit data precision!
* (Would jutils.c be a more reasonable place to put this?)
*/
GLOBAL(JHUFF_TBL *)
jpeg_std_huff_table (j_common_ptr cinfo, boolean isDC, int tblno)
{
JHUFF_TBL **htblptr, *htbl;
const UINT8 *bits, *val;
int nsymbols, len;
static const UINT8 bits_dc_luminance[17] =
{ /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 };
static const UINT8 val_dc_luminance[] =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
static const UINT8 bits_dc_chrominance[17] =
{ /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 };
static const UINT8 val_dc_chrominance[] =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
static const UINT8 bits_ac_luminance[17] =
{ /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d };
static const UINT8 val_ac_luminance[] =
{ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28,
0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4,
0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
0xf9, 0xfa };
static const UINT8 bits_ac_chrominance[17] =
{ /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 };
static const UINT8 val_ac_chrominance[] =
{ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,
0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,
0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26,
0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38,
0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3,
0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
0xf9, 0xfa };
if (cinfo->is_decompressor) {
if (isDC)
htblptr = ((j_decompress_ptr) cinfo)->dc_huff_tbl_ptrs;
else
htblptr = ((j_decompress_ptr) cinfo)->ac_huff_tbl_ptrs;
} else {
if (isDC)
htblptr = ((j_compress_ptr) cinfo)->dc_huff_tbl_ptrs;
else
htblptr = ((j_compress_ptr) cinfo)->ac_huff_tbl_ptrs;
}
switch (tblno) {
case 0:
if (isDC) {
bits = bits_dc_luminance;
val = val_dc_luminance;
} else {
bits = bits_ac_luminance;
val = val_ac_luminance;
}
break;
case 1:
if (isDC) {
bits = bits_dc_chrominance;
val = val_dc_chrominance;
} else {
bits = bits_ac_chrominance;
val = val_ac_chrominance;
}
break;
default:
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
return NULL; /* avoid compiler warnings for uninitialized variables */
}
if (htblptr[tblno] == NULL)
htblptr[tblno] = jpeg_alloc_huff_table(cinfo);
htbl = htblptr[tblno];
/* Copy the number-of-symbols-of-each-code-length counts */
MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits));
/* Validate the counts. We do this here mainly so we can copy the right
* number of symbols from the val[] array, without risking marching off
* the end of memory. jxhuff.c will do a more thorough test later.
*/
nsymbols = 0;
for (len = 1; len <= 16; len++)
nsymbols += bits[len];
if (nsymbols > 256)
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
if (nsymbols > 0)
MEMCOPY(htbl->huffval, val, nsymbols * SIZEOF(UINT8));
/* Initialize sent_table FALSE so table will be written to JPEG file. */
htbl->sent_table = FALSE;
return htbl;
}
+14 -103
View File
@@ -2,7 +2,7 @@
* jcparam.c
*
* Copyright (C) 1991-1998, Thomas G. Lane.
* Modified 2003-2013 by Guido Vollbeding.
* Modified 2003-2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -162,112 +162,23 @@ jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline)
/*
* Huffman table setup routines
* Reset standard Huffman tables
*/
LOCAL(void)
add_huff_table (j_compress_ptr cinfo,
JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val)
/* Define a Huffman table */
{
int nsymbols, len;
if (*htblptr == NULL)
*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
/* Copy the number-of-symbols-of-each-code-length counts */
MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits));
/* Validate the counts. We do this here mainly so we can copy the right
* number of symbols from the val[] array, without risking marching off
* the end of memory. jchuff.c will do a more thorough test later.
*/
nsymbols = 0;
for (len = 1; len <= 16; len++)
nsymbols += bits[len];
if (nsymbols < 1 || nsymbols > 256)
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
MEMCOPY((*htblptr)->huffval, val, nsymbols * SIZEOF(UINT8));
/* Initialize sent_table FALSE so table will be written to JPEG file. */
(*htblptr)->sent_table = FALSE;
}
LOCAL(void)
std_huff_tables (j_compress_ptr cinfo)
/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */
/* IMPORTANT: these are only valid for 8-bit data precision! */
{
static const UINT8 bits_dc_luminance[17] =
{ /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 };
static const UINT8 val_dc_luminance[] =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
static const UINT8 bits_dc_chrominance[17] =
{ /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 };
static const UINT8 val_dc_chrominance[] =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
static const UINT8 bits_ac_luminance[17] =
{ /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d };
static const UINT8 val_ac_luminance[] =
{ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28,
0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4,
0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
0xf9, 0xfa };
static const UINT8 bits_ac_chrominance[17] =
{ /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 };
static const UINT8 val_ac_chrominance[] =
{ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,
0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,
0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26,
0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38,
0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3,
0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
0xf9, 0xfa };
add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[0],
bits_dc_luminance, val_dc_luminance);
add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[0],
bits_ac_luminance, val_ac_luminance);
add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[1],
bits_dc_chrominance, val_dc_chrominance);
add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[1],
bits_ac_chrominance, val_ac_chrominance);
if (cinfo->dc_huff_tbl_ptrs[0] != NULL)
(void) jpeg_std_huff_table((j_common_ptr) cinfo, TRUE, 0);
if (cinfo->ac_huff_tbl_ptrs[0] != NULL)
(void) jpeg_std_huff_table((j_common_ptr) cinfo, FALSE, 0);
if (cinfo->dc_huff_tbl_ptrs[1] != NULL)
(void) jpeg_std_huff_table((j_common_ptr) cinfo, TRUE, 1);
if (cinfo->ac_huff_tbl_ptrs[1] != NULL)
(void) jpeg_std_huff_table((j_common_ptr) cinfo, FALSE, 1);
}
@@ -306,7 +217,7 @@ jpeg_set_defaults (j_compress_ptr cinfo)
cinfo->data_precision = BITS_IN_JSAMPLE;
/* Set up two quantization tables using default quality of 75 */
jpeg_set_quality(cinfo, 75, TRUE);
/* Set up two Huffman tables */
/* Reset standard Huffman tables */
std_huff_tables(cinfo);
/* Initialize default arithmetic coding conditioning */
+14 -14
View File
@@ -1,7 +1,7 @@
/*
* jdarith.c
*
* Developed 1997-2015 by Guido Vollbeding.
* Developed 1997-2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -280,7 +280,7 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
if ((m = arith_decode(cinfo, st)) != 0) {
st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
while (arith_decode(cinfo, st)) {
if ((m <<= 1) == 0x8000) {
if ((m <<= 1) == (int) 0x8000U) {
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
entropy->ct = -1; /* magnitude overflow */
return TRUE;
@@ -370,7 +370,7 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
st = entropy->ac_stats[tbl] +
(k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
while (arith_decode(cinfo, st)) {
if ((m <<= 1) == 0x8000) {
if ((m <<= 1) == (int) 0x8000U) {
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
entropy->ct = -1; /* magnitude overflow */
return TRUE;
@@ -404,7 +404,8 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
unsigned char *st;
int p1, blkn;
JCOEF p1;
int blkn;
/* Process restart marker if needed */
if (cinfo->restart_interval) {
@@ -440,7 +441,7 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
JCOEFPTR thiscoef;
unsigned char *st;
int tbl, k, kex;
int p1, m1;
JCOEF p1, m1;
const int * natural_order;
/* Process restart marker if needed */
@@ -459,7 +460,7 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
tbl = cinfo->cur_comp_info[0]->ac_tbl_no;
p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */
m1 = -p1; /* -1 in the bit position being coded */
/* Establish EOBx (previous stage end-of-block) index */
kex = cinfo->Se;
@@ -555,7 +556,7 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
if ((m = arith_decode(cinfo, st)) != 0) {
st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
while (arith_decode(cinfo, st)) {
if ((m <<= 1) == 0x8000) {
if ((m <<= 1) == (int) 0x8000U) {
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
entropy->ct = -1; /* magnitude overflow */
return TRUE;
@@ -612,7 +613,7 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
st = entropy->ac_stats[tbl] +
(k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
while (arith_decode(cinfo, st)) {
if ((m <<= 1) == 0x8000) {
if ((m <<= 1) == (int) 0x8000U) {
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
entropy->ct = -1; /* magnitude overflow */
return TRUE;
@@ -766,9 +767,8 @@ jinit_arith_decoder (j_decompress_ptr cinfo)
arith_entropy_ptr entropy;
int i;
entropy = (arith_entropy_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(arith_entropy_decoder));
entropy = (arith_entropy_ptr) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(arith_entropy_decoder));
cinfo->entropy = &entropy->pub;
entropy->pub.start_pass = start_pass;
entropy->pub.finish_pass = finish_pass;
@@ -785,9 +785,9 @@ jinit_arith_decoder (j_decompress_ptr cinfo)
if (cinfo->progressive_mode) {
/* Create progression status table */
int *coef_bit_ptr, ci;
cinfo->coef_bits = (int (*)[DCTSIZE2])
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
cinfo->num_components*DCTSIZE2*SIZEOF(int));
cinfo->coef_bits = (int (*)[DCTSIZE2]) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE,
cinfo->num_components * DCTSIZE2 * SIZEOF(int));
coef_bit_ptr = & cinfo->coef_bits[0][0];
for (ci = 0; ci < cinfo->num_components; ci++)
for (i = 0; i < DCTSIZE2; i++)
+10 -13
View File
@@ -2,7 +2,7 @@
* jdatadst.c
*
* Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2009-2017 by Guido Vollbeding.
* Modified 2009-2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -46,7 +46,7 @@ typedef struct {
struct jpeg_destination_mgr pub; /* public fields */
unsigned char ** outbuffer; /* target buffer */
unsigned long * outsize;
size_t * outsize;
unsigned char * newbuffer; /* newly allocated buffer */
JOCTET * buffer; /* start of buffer */
size_t bufsize;
@@ -66,9 +66,8 @@ init_destination (j_compress_ptr cinfo)
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
/* Allocate the output buffer --- it will be released when done with image */
dest->buffer = (JOCTET *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
OUTPUT_BUF_SIZE * SIZEOF(JOCTET));
dest->buffer = (JOCTET *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, OUTPUT_BUF_SIZE * SIZEOF(JOCTET));
dest->pub.next_output_byte = dest->buffer;
dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
@@ -131,7 +130,7 @@ empty_mem_output_buffer (j_compress_ptr cinfo)
nextbuffer = (JOCTET *) malloc(nextsize);
if (nextbuffer == NULL)
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 11);
MEMCOPY(nextbuffer, dest->buffer, dest->bufsize);
@@ -204,9 +203,8 @@ jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile)
* sizes may be different. Caveat programmer.
*/
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
cinfo->dest = (struct jpeg_destination_mgr *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
SIZEOF(my_destination_mgr));
cinfo->dest = (struct jpeg_destination_mgr *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_destination_mgr));
}
dest = (my_dest_ptr) cinfo->dest;
@@ -233,7 +231,7 @@ jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile)
GLOBAL(void)
jpeg_mem_dest (j_compress_ptr cinfo,
unsigned char ** outbuffer, unsigned long * outsize)
unsigned char ** outbuffer, size_t * outsize)
{
my_mem_dest_ptr dest;
@@ -244,9 +242,8 @@ jpeg_mem_dest (j_compress_ptr cinfo,
* can be written to the same buffer without re-executing jpeg_mem_dest.
*/
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
cinfo->dest = (struct jpeg_destination_mgr *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
SIZEOF(my_mem_destination_mgr));
cinfo->dest = (struct jpeg_destination_mgr *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_mem_destination_mgr));
}
dest = (my_mem_dest_ptr) cinfo->dest;
+15 -16
View File
@@ -2,7 +2,7 @@
* jdatasrc.c
*
* Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2009-2015 by Guido Vollbeding.
* Modified 2009-2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -156,21 +156,23 @@ METHODDEF(void)
skip_input_data (j_decompress_ptr cinfo, long num_bytes)
{
struct jpeg_source_mgr * src = cinfo->src;
size_t nbytes;
/* Just a dumb implementation for now. Could use fseek() except
* it doesn't work on pipes. Not clear that being smart is worth
* any trouble anyway --- large skips are infrequent.
*/
if (num_bytes > 0) {
while (num_bytes > (long) src->bytes_in_buffer) {
num_bytes -= (long) src->bytes_in_buffer;
nbytes = (size_t) num_bytes;
while (nbytes > src->bytes_in_buffer) {
nbytes -= src->bytes_in_buffer;
(void) (*src->fill_input_buffer) (cinfo);
/* note we assume that fill_input_buffer will never return FALSE,
* so suspension need not be handled.
*/
}
src->next_input_byte += (size_t) num_bytes;
src->bytes_in_buffer -= (size_t) num_bytes;
src->next_input_byte += nbytes;
src->bytes_in_buffer -= nbytes;
}
}
@@ -219,13 +221,11 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile)
* manager serially with the same JPEG object. Caveat programmer.
*/
if (cinfo->src == NULL) { /* first time for this JPEG object? */
cinfo->src = (struct jpeg_source_mgr *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
SIZEOF(my_source_mgr));
cinfo->src = (struct jpeg_source_mgr *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_source_mgr));
src = (my_src_ptr) cinfo->src;
src->buffer = (JOCTET *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
INPUT_BUF_SIZE * SIZEOF(JOCTET));
src->buffer = (JOCTET *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_PERMANENT, INPUT_BUF_SIZE * SIZEOF(JOCTET));
}
src = (my_src_ptr) cinfo->src;
@@ -247,7 +247,7 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile)
GLOBAL(void)
jpeg_mem_src (j_decompress_ptr cinfo,
const unsigned char * inbuffer, unsigned long insize)
const unsigned char * inbuffer, size_t insize)
{
struct jpeg_source_mgr * src;
@@ -259,9 +259,8 @@ jpeg_mem_src (j_decompress_ptr cinfo,
* the first one.
*/
if (cinfo->src == NULL) { /* first time for this JPEG object? */
cinfo->src = (struct jpeg_source_mgr *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
SIZEOF(struct jpeg_source_mgr));
cinfo->src = (struct jpeg_source_mgr *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(struct jpeg_source_mgr));
}
src = cinfo->src;
@@ -270,6 +269,6 @@ jpeg_mem_src (j_decompress_ptr cinfo,
src->skip_input_data = skip_input_data;
src->resync_to_restart = jpeg_resync_to_restart; /* use default method */
src->term_source = term_source;
src->bytes_in_buffer = (size_t) insize;
src->bytes_in_buffer = insize;
src->next_input_byte = (const JOCTET *) inbuffer;
}
+59 -71
View File
@@ -2,7 +2,7 @@
* jdcolor.c
*
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2011-2017 by Guido Vollbeding.
* Modified 2011-2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -124,28 +124,22 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
INT32 x;
SHIFT_TEMPS
cconvert->Cr_r_tab = (int *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(int));
cconvert->Cb_b_tab = (int *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(int));
cconvert->Cr_g_tab = (INT32 *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(INT32));
cconvert->Cb_g_tab = (INT32 *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(INT32));
cconvert->Cr_r_tab = (int *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
cconvert->Cb_b_tab = (int *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
cconvert->Cr_g_tab = (INT32 *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
cconvert->Cb_g_tab = (INT32 *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
/* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
/* Cr=>R value is nearest int to 1.402 * x */
cconvert->Cr_r_tab[i] = (int)
RIGHT_SHIFT(FIX(1.402) * x + ONE_HALF, SCALEBITS);
cconvert->Cr_r_tab[i] = (int) DESCALE(FIX(1.402) * x, SCALEBITS);
/* Cb=>B value is nearest int to 1.772 * x */
cconvert->Cb_b_tab[i] = (int)
RIGHT_SHIFT(FIX(1.772) * x + ONE_HALF, SCALEBITS);
cconvert->Cb_b_tab[i] = (int) DESCALE(FIX(1.772) * x, SCALEBITS);
/* Cr=>G value is scaled-up -0.714136286 * x */
cconvert->Cr_g_tab[i] = (- FIX(0.714136286)) * x;
/* Cb=>G value is scaled-up -0.344136286 * x */
@@ -164,28 +158,22 @@ build_bg_ycc_rgb_table (j_decompress_ptr cinfo)
INT32 x;
SHIFT_TEMPS
cconvert->Cr_r_tab = (int *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(int));
cconvert->Cb_b_tab = (int *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(int));
cconvert->Cr_g_tab = (INT32 *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(INT32));
cconvert->Cb_g_tab = (INT32 *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(INT32));
cconvert->Cr_r_tab = (int *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
cconvert->Cb_b_tab = (int *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
cconvert->Cr_g_tab = (INT32 *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
cconvert->Cb_g_tab = (INT32 *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
/* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
/* Cr=>R value is nearest int to 2.804 * x */
cconvert->Cr_r_tab[i] = (int)
RIGHT_SHIFT(FIX(2.804) * x + ONE_HALF, SCALEBITS);
cconvert->Cr_r_tab[i] = (int) DESCALE(FIX(2.804) * x, SCALEBITS);
/* Cb=>B value is nearest int to 3.544 * x */
cconvert->Cb_b_tab[i] = (int)
RIGHT_SHIFT(FIX(3.544) * x + ONE_HALF, SCALEBITS);
cconvert->Cb_b_tab[i] = (int) DESCALE(FIX(3.544) * x, SCALEBITS);
/* Cr=>G value is scaled-up -1.428272572 * x */
cconvert->Cr_g_tab[i] = (- FIX(1.428272572)) * x;
/* Cb=>G value is scaled-up -0.688272572 * x */
@@ -201,6 +189,7 @@ build_bg_ycc_rgb_table (j_decompress_ptr cinfo)
* Note that we change from noninterleaved, one-plane-per-component format
* to interleaved-pixel format. The output buffer is therefore three times
* as wide as the input buffer.
*
* A starting row offset is provided only for the input buffer. The caller
* can easily adjust the passed output_buf value to accommodate any row
* offset required on that side.
@@ -264,9 +253,8 @@ build_rgb_y_table (j_decompress_ptr cinfo)
INT32 i;
/* Allocate and fill in the conversion tables. */
cconvert->rgb_y_tab = rgb_y_tab = (INT32 *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(TABLE_SIZE * SIZEOF(INT32)));
cconvert->rgb_y_tab = rgb_y_tab = (INT32 *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, TABLE_SIZE * SIZEOF(INT32));
for (i = 0; i <= MAXJSAMPLE; i++) {
rgb_y_tab[i+R_Y_OFF] = FIX(0.299) * i;
@@ -286,8 +274,8 @@ rgb_gray_convert (j_decompress_ptr cinfo,
JSAMPARRAY output_buf, int num_rows)
{
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
register INT32 * ctab = cconvert->rgb_y_tab;
register int r, g, b;
register INT32 * ctab = cconvert->rgb_y_tab;
register JSAMPROW outptr;
register JSAMPROW inptr0, inptr1, inptr2;
register JDIMENSION col;
@@ -313,6 +301,7 @@ rgb_gray_convert (j_decompress_ptr cinfo,
/*
* Convert some rows of samples to the output colorspace.
* [R-G,G,B-G] to [R,G,B] conversion with modulo calculation
* (inverse color transform).
* This can be seen as an adaption of the general YCbCr->RGB
@@ -364,8 +353,8 @@ rgb1_gray_convert (j_decompress_ptr cinfo,
JSAMPARRAY output_buf, int num_rows)
{
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
register INT32 * ctab = cconvert->rgb_y_tab;
register int r, g, b;
register INT32 * ctab = cconvert->rgb_y_tab;
register JSAMPROW outptr;
register JSAMPROW inptr0, inptr1, inptr2;
register JDIMENSION col;
@@ -396,6 +385,7 @@ rgb1_gray_convert (j_decompress_ptr cinfo,
/*
* Convert some rows of samples to the output colorspace.
* No colorspace change, but conversion from separate-planes
* to interleaved representation.
*/
@@ -430,6 +420,7 @@ rgb_convert (j_decompress_ptr cinfo,
/*
* Color conversion for no colorspace change: just copy the data,
* converting from separate-planes to interleaved representation.
* We assume out_color_components == num_components.
*/
METHODDEF(void)
@@ -437,20 +428,21 @@ null_convert (j_decompress_ptr cinfo,
JSAMPIMAGE input_buf, JDIMENSION input_row,
JSAMPARRAY output_buf, int num_rows)
{
int ci;
register int nc = cinfo->num_components;
register JSAMPROW outptr;
register JSAMPROW inptr;
register JDIMENSION col;
register JDIMENSION count;
register int num_comps = cinfo->num_components;
JDIMENSION num_cols = cinfo->output_width;
int ci;
while (--num_rows >= 0) {
for (ci = 0; ci < nc; ci++) {
/* It seems fastest to make a separate pass for each component. */
for (ci = 0; ci < num_comps; ci++) {
inptr = input_buf[ci][input_row];
outptr = output_buf[0] + ci;
for (col = 0; col < num_cols; col++) {
*outptr = *inptr++; /* needn't bother with GETJSAMPLE() here */
outptr += nc;
for (count = num_cols; count > 0; count--) {
*outptr = *inptr++; /* don't need GETJSAMPLE() here */
outptr += num_comps;
}
}
input_row++;
@@ -504,9 +496,10 @@ gray_rgb_convert (j_decompress_ptr cinfo,
/*
* Adobe-style YCCK->CMYK conversion.
* We convert YCbCr to R=1-C, G=1-M, and B=1-Y using the same
* conversion as above, while passing K (black) unchanged.
* Convert some rows of samples to the output colorspace.
* This version handles Adobe-style YCCK->CMYK conversion,
* where we convert YCbCr to R=1-C, G=1-M, and B=1-Y using the
* same conversion as above, while passing K (black) unchanged.
* We assume build_ycc_rgb_table has been called.
*/
@@ -577,9 +570,8 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
my_cconvert_ptr cconvert;
int ci;
cconvert = (my_cconvert_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_color_deconverter));
cconvert = (my_cconvert_ptr) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_color_deconverter));
cinfo->cconvert = &cconvert->pub;
cconvert->pub.start_pass = start_pass_dcolor;
@@ -607,7 +599,6 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
default: /* JCS_UNKNOWN can be anything */
if (cinfo->num_components < 1)
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
break;
}
/* Support color transform only for RGB colorspaces */
@@ -684,19 +675,18 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
case JCS_BG_RGB:
cinfo->out_color_components = RGB_PIXELSIZE;
if (cinfo->jpeg_color_space == JCS_BG_RGB) {
switch (cinfo->color_transform) {
case JCT_NONE:
cconvert->pub.color_convert = rgb_convert;
break;
case JCT_SUBTRACT_GREEN:
cconvert->pub.color_convert = rgb1_rgb_convert;
break;
default:
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
}
} else
if (cinfo->jpeg_color_space != JCS_BG_RGB)
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
switch (cinfo->color_transform) {
case JCT_NONE:
cconvert->pub.color_convert = rgb_convert;
break;
case JCT_SUBTRACT_GREEN:
cconvert->pub.color_convert = rgb1_rgb_convert;
break;
default:
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
}
break;
case JCS_CMYK:
@@ -714,14 +704,12 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
}
break;
default:
/* Permit null conversion to same output space */
if (cinfo->out_color_space == cinfo->jpeg_color_space) {
cinfo->out_color_components = cinfo->num_components;
cconvert->pub.color_convert = null_convert;
} else /* unsupported non-null conversion */
default: /* permit null conversion to same output space */
if (cinfo->out_color_space != cinfo->jpeg_color_space)
/* unsupported non-null conversion */
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
break;
cinfo->out_color_components = cinfo->num_components;
cconvert->pub.color_convert = null_convert;
}
if (cinfo->quantize_colors)
+1 -8
View File
@@ -2,7 +2,7 @@
* jdct.h
*
* Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2002-2017 by Guido Vollbeding.
* Modified 2002-2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -358,13 +358,6 @@ EXTERN(void) jpeg_idct_1x2
#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5))
/* Descale and correctly round an INT32 value that's scaled by N bits.
* We assume RIGHT_SHIFT rounds towards minus infinity, so adding
* the fudge factor is correct for either sign of X.
*/
#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.
* This macro is used only when the two inputs will actually be no more than
* 16 bits wide, so that a 16x16->32 bit multiply can be used instead of a
+56 -50
View File
@@ -2,7 +2,7 @@
* jdhuff.c
*
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2006-2016 by Guido Vollbeding.
* Modified 2006-2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -341,13 +341,12 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
htbl =
isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno];
if (htbl == NULL)
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
htbl = jpeg_std_huff_table((j_common_ptr) cinfo, isDC, tblno);
/* Allocate a workspace if we haven't already done so. */
if (*pdtbl == NULL)
*pdtbl = (d_derived_tbl *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(d_derived_tbl));
*pdtbl = (d_derived_tbl *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(d_derived_tbl));
dtbl = *pdtbl;
dtbl->pub = htbl; /* fill in back link */
@@ -706,7 +705,7 @@ process_restart (j_decompress_ptr cinfo)
METHODDEF(boolean)
decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
{
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
int Al = cinfo->Al;
register int s, r;
@@ -730,7 +729,7 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
if (! entropy->insufficient_data) {
/* Load up working state */
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
ASSIGN_STATE(state, entropy->saved);
/* Outer loop handles each block in the MCU */
@@ -759,12 +758,13 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
}
/* Completed MCU, so update state */
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
ASSIGN_STATE(entropy->saved, state);
}
/* Account for restart interval (no-op if not using restarts) */
entropy->restarts_to_go--;
/* Account for restart interval if using restarts */
if (cinfo->restart_interval)
entropy->restarts_to_go--;
return TRUE;
}
@@ -777,7 +777,7 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
METHODDEF(boolean)
decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
{
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
register int s, k, r;
unsigned int EOBRUN;
@@ -809,7 +809,7 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
if (EOBRUN) /* if it's a band of zeroes... */
EOBRUN--; /* ...process it now (we do nothing) */
else {
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
Se = cinfo->Se;
Al = cinfo->Al;
natural_order = cinfo->natural_order;
@@ -842,15 +842,16 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
}
}
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
}
/* Completed MCU, so update state */
entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */
}
/* Account for restart interval (no-op if not using restarts) */
entropy->restarts_to_go--;
/* Account for restart interval if using restarts */
if (cinfo->restart_interval)
entropy->restarts_to_go--;
return TRUE;
}
@@ -864,9 +865,10 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
METHODDEF(boolean)
decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
{
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
int p1, blkn;
JCOEF p1;
int blkn;
BITREAD_STATE_VARS;
/* Process restart marker if needed; may have to suspend */
@@ -881,7 +883,7 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
*/
/* Load up working state */
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
@@ -896,10 +898,11 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
}
/* Completed MCU, so update state */
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
/* Account for restart interval (no-op if not using restarts) */
entropy->restarts_to_go--;
/* Account for restart interval if using restarts */
if (cinfo->restart_interval)
entropy->restarts_to_go--;
return TRUE;
}
@@ -911,11 +914,12 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
METHODDEF(boolean)
decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
{
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
register int s, k, r;
unsigned int EOBRUN;
int Se, p1, m1;
int Se;
JCOEF p1, m1;
const int * natural_order;
JBLOCKROW block;
JCOEFPTR thiscoef;
@@ -937,11 +941,11 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
Se = cinfo->Se;
p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */
m1 = -p1; /* -1 in the bit position being coded */
natural_order = cinfo->natural_order;
/* Load up working state */
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */
/* There is always only one block per MCU */
@@ -1043,12 +1047,13 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
}
/* Completed MCU, so update state */
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */
}
/* Account for restart interval (no-op if not using restarts) */
entropy->restarts_to_go--;
/* Account for restart interval if using restarts */
if (cinfo->restart_interval)
entropy->restarts_to_go--;
return TRUE;
@@ -1091,7 +1096,7 @@ decode_mcu_sub (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
Se = cinfo->lim_Se;
/* Load up working state */
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
ASSIGN_STATE(state, entropy->saved);
/* Outer loop handles each block in the MCU */
@@ -1178,12 +1183,13 @@ decode_mcu_sub (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
}
/* Completed MCU, so update state */
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
ASSIGN_STATE(entropy->saved, state);
}
/* Account for restart interval (no-op if not using restarts) */
entropy->restarts_to_go--;
/* Account for restart interval if using restarts */
if (cinfo->restart_interval)
entropy->restarts_to_go--;
return TRUE;
}
@@ -1215,7 +1221,7 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
if (! entropy->insufficient_data) {
/* Load up working state */
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
ASSIGN_STATE(state, entropy->saved);
/* Outer loop handles each block in the MCU */
@@ -1302,12 +1308,13 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
}
/* Completed MCU, so update state */
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
ASSIGN_STATE(entropy->saved, state);
}
/* Account for restart interval (no-op if not using restarts) */
entropy->restarts_to_go--;
/* Account for restart interval if using restarts */
if (cinfo->restart_interval)
entropy->restarts_to_go--;
return TRUE;
}
@@ -1343,11 +1350,11 @@ start_pass_huff_decoder (j_decompress_ptr cinfo)
goto bad;
}
if (cinfo->Al > 13) { /* need not check for < 0 */
/* Arguably the maximum Al value should be less than 13 for 8-bit precision,
* but the spec doesn't say so, and we try to be liberal about what we
* accept. Note: large Al values could result in out-of-range DC
* coefficients during early scans, leading to bizarre displays due to
* overflows in the IDCT math. But we won't crash.
/* Arguably the maximum Al value should be less than 13 for 8-bit
* precision, but the spec doesn't say so, and we try to be liberal
* about what we accept. Note: large Al values could result in
* out-of-range DC coefficients during early scans, leading to bizarre
* displays due to overflows in the IDCT math. But we won't crash.
*/
bad:
ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
@@ -1451,7 +1458,8 @@ start_pass_huff_decoder (j_decompress_ptr cinfo)
compptr = cinfo->cur_comp_info[ci];
/* Precalculate which table to use for each block */
entropy->dc_cur_tbls[blkn] = entropy->dc_derived_tbls[compptr->dc_tbl_no];
entropy->ac_cur_tbls[blkn] = entropy->ac_derived_tbls[compptr->ac_tbl_no];
entropy->ac_cur_tbls[blkn] = /* AC needs no table when not present */
cinfo->lim_Se ? entropy->ac_derived_tbls[compptr->ac_tbl_no] : NULL;
/* Decide whether we really care about the coefficient values */
if (compptr->component_needed) {
ci = compptr->DCT_v_scaled_size;
@@ -1494,7 +1502,6 @@ start_pass_huff_decoder (j_decompress_ptr cinfo)
if (ci <= 0 || ci > 8) ci = 8;
if (i <= 0 || i > 8) i = 8;
entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order[ci - 1][i - 1];
break;
}
} else {
entropy->coef_limit[blkn] = 0;
@@ -1522,9 +1529,8 @@ jinit_huff_decoder (j_decompress_ptr cinfo)
huff_entropy_ptr entropy;
int i;
entropy = (huff_entropy_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(huff_entropy_decoder));
entropy = (huff_entropy_ptr) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(huff_entropy_decoder));
cinfo->entropy = &entropy->pub;
entropy->pub.start_pass = start_pass_huff_decoder;
entropy->pub.finish_pass = finish_pass_huff;
@@ -1532,9 +1538,9 @@ jinit_huff_decoder (j_decompress_ptr cinfo)
if (cinfo->progressive_mode) {
/* Create progression status table */
int *coef_bit_ptr, ci;
cinfo->coef_bits = (int (*)[DCTSIZE2])
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
cinfo->num_components*DCTSIZE2*SIZEOF(int));
cinfo->coef_bits = (int (*)[DCTSIZE2]) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE,
cinfo->num_components * DCTSIZE2 * SIZEOF(int));
coef_bit_ptr = & cinfo->coef_bits[0][0];
for (ci = 0; ci < cinfo->num_components; ci++)
for (i = 0; i < DCTSIZE2; i++)
@@ -1545,7 +1551,7 @@ jinit_huff_decoder (j_decompress_ptr cinfo)
entropy->derived_tbls[i] = NULL;
}
} else {
/* Mark tables unallocated */
/* Mark derived tables unallocated */
for (i = 0; i < NUM_HUFF_TBLS; i++) {
entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL;
}
+7 -13
View File
@@ -2,7 +2,7 @@
* jdmarker.c
*
* Copyright (C) 1991-1998, Thomas G. Lane.
* Modified 2009-2013 by Guido Vollbeding.
* Modified 2009-2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -496,8 +496,6 @@ get_dht (j_decompress_ptr cinfo)
if (count > 256 || ((INT32) count) > length)
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
MEMZERO(huffval, SIZEOF(huffval)); /* pre-zero array for later copy */
for (i = 0; i < count; i++)
INPUT_BYTE(cinfo, huffval[i], return FALSE);
@@ -517,7 +515,8 @@ get_dht (j_decompress_ptr cinfo)
*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits));
MEMCOPY((*htblptr)->huffval, huffval, SIZEOF((*htblptr)->huffval));
if (count > 0)
MEMCOPY((*htblptr)->huffval, huffval, count * SIZEOF(UINT8));
}
if (length != 0)
@@ -577,14 +576,14 @@ get_dqt (j_decompress_ptr cinfo)
count = DCTSIZE2;
}
switch (count) {
switch ((int) count) {
case (2*2): natural_order = jpeg_natural_order2; break;
case (3*3): natural_order = jpeg_natural_order3; break;
case (4*4): natural_order = jpeg_natural_order4; break;
case (5*5): natural_order = jpeg_natural_order5; break;
case (6*6): natural_order = jpeg_natural_order6; break;
case (7*7): natural_order = jpeg_natural_order7; break;
default: natural_order = jpeg_natural_order; break;
default: natural_order = jpeg_natural_order;
}
for (i = 0; i < count; i++) {
@@ -784,7 +783,6 @@ examine_app0 (j_decompress_ptr cinfo, JOCTET FAR * data,
default:
TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION,
GETJOCTET(data[5]), (int) totallen);
break;
}
} else {
/* Start of APP0 does not match "JFIF" or "JFXX", or too short */
@@ -858,7 +856,6 @@ get_interesting_appn (j_decompress_ptr cinfo)
default:
/* can't get here unless jpeg_save_markers chooses wrong processor */
ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
break;
}
/* skip any remaining data -- could be lots */
@@ -964,7 +961,6 @@ save_marker (j_decompress_ptr cinfo)
default:
TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker,
(int) (data_length + length));
break;
}
/* skip any remaining data -- could be lots */
@@ -1240,7 +1236,6 @@ read_markers (j_decompress_ptr cinfo)
* ought to change!
*/
ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
break;
}
/* Successfully processed marker, so reset state variable */
cinfo->unread_marker = 0;
@@ -1416,9 +1411,8 @@ jinit_marker_reader (j_decompress_ptr cinfo)
int i;
/* Create subobject in permanent pool */
marker = (my_marker_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
SIZEOF(my_marker_reader));
marker = (my_marker_ptr) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_marker_reader));
cinfo->marker = &marker->pub;
/* Initialize public method pointers */
marker->pub.reset_marker_reader = reset_marker_reader;
+24 -23
View File
@@ -2,7 +2,7 @@
* jdmaster.c
*
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2002-2017 by Guido Vollbeding.
* Modified 2002-2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -104,7 +104,7 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
*/
{
#ifdef IDCT_SCALING_SUPPORTED
int ci;
int ci, ssize;
jpeg_component_info *compptr;
#endif
@@ -124,19 +124,23 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
*/
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
int ssize = 1;
while (cinfo->min_DCT_h_scaled_size * ssize <=
(cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) &&
(cinfo->max_h_samp_factor % (compptr->h_samp_factor * ssize * 2)) == 0) {
ssize = ssize * 2;
}
ssize = 1;
if (! cinfo->raw_data_out)
while (cinfo->min_DCT_h_scaled_size * ssize <=
(cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) &&
(cinfo->max_h_samp_factor % (compptr->h_samp_factor * ssize * 2)) ==
0) {
ssize = ssize * 2;
}
compptr->DCT_h_scaled_size = cinfo->min_DCT_h_scaled_size * ssize;
ssize = 1;
while (cinfo->min_DCT_v_scaled_size * ssize <=
(cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) &&
(cinfo->max_v_samp_factor % (compptr->v_samp_factor * ssize * 2)) == 0) {
ssize = ssize * 2;
}
if (! cinfo->raw_data_out)
while (cinfo->min_DCT_v_scaled_size * ssize <=
(cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) &&
(cinfo->max_v_samp_factor % (compptr->v_samp_factor * ssize * 2)) ==
0) {
ssize = ssize * 2;
}
compptr->DCT_v_scaled_size = cinfo->min_DCT_v_scaled_size * ssize;
/* We don't support IDCT ratios larger than 2. */
@@ -144,13 +148,10 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size * 2;
else if (compptr->DCT_v_scaled_size > compptr->DCT_h_scaled_size * 2)
compptr->DCT_v_scaled_size = compptr->DCT_h_scaled_size * 2;
}
/* Recompute downsampled dimensions of components;
* application needs to know these if using raw downsampled data.
*/
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
/* Recompute downsampled dimensions of components;
* application needs to know these if using raw downsampled data.
*/
/* Size in samples, after IDCT scaling */
compptr->downsampled_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width *
@@ -172,8 +173,10 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
break;
case JCS_RGB:
case JCS_BG_RGB:
#if RGB_PIXELSIZE != 3
cinfo->out_color_components = RGB_PIXELSIZE;
break;
#endif /* else share code with YCbCr */
case JCS_YCbCr:
case JCS_BG_YCC:
cinfo->out_color_components = 3;
@@ -184,7 +187,6 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
break;
default: /* else must be same colorspace as in file */
cinfo->out_color_components = cinfo->num_components;
break;
}
cinfo->output_components = (cinfo->quantize_colors ? 1 :
cinfo->out_color_components);
@@ -525,9 +527,8 @@ jinit_master_decompress (j_decompress_ptr cinfo)
{
my_master_ptr master;
master = (my_master_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_decomp_master));
master = (my_master_ptr) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_decomp_master));
cinfo->master = &master->pub;
master->pub.prepare_for_output_pass = prepare_for_output_pass;
master->pub.finish_output_pass = finish_output_pass;
+26 -39
View File
@@ -2,7 +2,7 @@
* jdmerge.c
*
* Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2013-2017 by Guido Vollbeding.
* Modified 2013-2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -95,28 +95,22 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
INT32 x;
SHIFT_TEMPS
upsample->Cr_r_tab = (int *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(int));
upsample->Cb_b_tab = (int *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(int));
upsample->Cr_g_tab = (INT32 *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(INT32));
upsample->Cb_g_tab = (INT32 *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(INT32));
upsample->Cr_r_tab = (int *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
upsample->Cb_b_tab = (int *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
upsample->Cr_g_tab = (INT32 *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
upsample->Cb_g_tab = (INT32 *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
/* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
/* Cr=>R value is nearest int to 1.402 * x */
upsample->Cr_r_tab[i] = (int)
RIGHT_SHIFT(FIX(1.402) * x + ONE_HALF, SCALEBITS);
upsample->Cr_r_tab[i] = (int) DESCALE(FIX(1.402) * x, SCALEBITS);
/* Cb=>B value is nearest int to 1.772 * x */
upsample->Cb_b_tab[i] = (int)
RIGHT_SHIFT(FIX(1.772) * x + ONE_HALF, SCALEBITS);
upsample->Cb_b_tab[i] = (int) DESCALE(FIX(1.772) * x, SCALEBITS);
/* Cr=>G value is scaled-up -0.714136286 * x */
upsample->Cr_g_tab[i] = (- FIX(0.714136286)) * x;
/* Cb=>G value is scaled-up -0.344136286 * x */
@@ -135,28 +129,22 @@ build_bg_ycc_rgb_table (j_decompress_ptr cinfo)
INT32 x;
SHIFT_TEMPS
upsample->Cr_r_tab = (int *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(int));
upsample->Cb_b_tab = (int *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(int));
upsample->Cr_g_tab = (INT32 *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(INT32));
upsample->Cb_g_tab = (INT32 *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(INT32));
upsample->Cr_r_tab = (int *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
upsample->Cb_b_tab = (int *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
upsample->Cr_g_tab = (INT32 *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
upsample->Cb_g_tab = (INT32 *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
/* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
/* Cr=>R value is nearest int to 2.804 * x */
upsample->Cr_r_tab[i] = (int)
RIGHT_SHIFT(FIX(2.804) * x + ONE_HALF, SCALEBITS);
upsample->Cr_r_tab[i] = (int) DESCALE(FIX(2.804) * x, SCALEBITS);
/* Cb=>B value is nearest int to 3.544 * x */
upsample->Cb_b_tab[i] = (int)
RIGHT_SHIFT(FIX(3.544) * x + ONE_HALF, SCALEBITS);
upsample->Cb_b_tab[i] = (int) DESCALE(FIX(3.544) * x, SCALEBITS);
/* Cr=>G value is scaled-up -1.428272572 * x */
upsample->Cr_g_tab[i] = (- FIX(1.428272572)) * x;
/* Cb=>G value is scaled-up -0.688272572 * x */
@@ -419,9 +407,8 @@ jinit_merged_upsampler (j_decompress_ptr cinfo)
{
my_upsample_ptr upsample;
upsample = (my_upsample_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_upsampler));
upsample = (my_upsample_ptr) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_upsampler));
cinfo->upsample = &upsample->pub;
upsample->pub.start_pass = start_pass_merged_upsample;
upsample->pub.need_context_rows = FALSE;
@@ -432,9 +419,9 @@ jinit_merged_upsampler (j_decompress_ptr cinfo)
upsample->pub.upsample = merged_2v_upsample;
upsample->upmethod = h2v2_merged_upsample;
/* Allocate a spare row buffer */
upsample->spare_row = (JSAMPROW)
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(size_t) (upsample->out_row_width * SIZEOF(JSAMPLE)));
upsample->spare_row = (JSAMPROW) (*cinfo->mem->alloc_large)
((j_common_ptr) cinfo, JPOOL_IMAGE,
(size_t) upsample->out_row_width * SIZEOF(JSAMPLE));
} else {
upsample->pub.upsample = merged_1v_upsample;
upsample->upmethod = h2v1_merged_upsample;
+2 -2
View File
@@ -2,7 +2,7 @@
* jerror.h
*
* Copyright (C) 1994-1997, Thomas G. Lane.
* Modified 1997-2012 by Guido Vollbeding.
* Modified 1997-2018 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -84,7 +84,7 @@ JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan")
JMESSAGE(JERR_FILE_READ, "Input file read error")
JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?")
JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet")
JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow")
JMESSAGE(JERR_HUFF_CLEN_OUTOFBOUNDS, "Huffman code size table out of bounds")
JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry")
JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels")
JMESSAGE(JERR_INPUT_EMPTY, "Empty input file")
+61 -55
View File
@@ -2,7 +2,7 @@
* jfdctint.c
*
* Copyright (C) 1991-1996, Thomas G. Lane.
* Modification developed 2003-2015 by Guido Vollbeding.
* Modification developed 2003-2018 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -3261,78 +3261,84 @@ jpeg_fdct_6x3 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
GLOBAL(void)
jpeg_fdct_4x2 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
{
INT32 tmp0, tmp1;
INT32 tmp10, tmp11;
DCTELEM *dataptr;
DCTELEM tmp0, tmp2, tmp10, tmp12, tmp4, tmp5;
INT32 tmp1, tmp3, tmp11, tmp13;
INT32 z1, z2, z3;
JSAMPROW elemptr;
int ctr;
SHIFT_TEMPS
/* Pre-zero output coefficient block. */
MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2);
/* Pass 1: process rows.
* Note results are scaled up by sqrt(8) compared to a true DCT;
* furthermore, we scale the results by 2**PASS1_BITS.
* We must also scale the output by (8/4)*(8/2) = 2**3, which we add here.
* Note results are scaled up by sqrt(8) compared to a true DCT.
* 4-point FDCT kernel,
* cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point FDCT].
*/
dataptr = data;
for (ctr = 0; ctr < 2; ctr++) {
elemptr = sample_data[ctr] + start_col;
/* Row 0 */
elemptr = sample_data[0] + start_col;
/* Even part */
/* Even part */
tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[3]);
tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[2]);
tmp4 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[3]);
tmp5 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[2]);
tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[3]);
tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[2]);
tmp0 = tmp4 + tmp5;
tmp2 = tmp4 - tmp5;
/* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM)
((tmp0 + tmp1 - 4 * CENTERJSAMPLE) << (PASS1_BITS+3));
dataptr[2] = (DCTELEM) ((tmp0 - tmp1) << (PASS1_BITS+3));
/* Odd part */
/* Odd part */
z2 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[3]);
z3 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[2]);
tmp0 = MULTIPLY(tmp10 + tmp11, FIX_0_541196100); /* c6 */
/* Add fudge factor here for final descale. */
tmp0 += ONE << (CONST_BITS-PASS1_BITS-4);
z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */
/* Add fudge factor here for final descale. */
z1 += ONE << (CONST_BITS-3-1);
tmp1 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */
tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */
dataptr[1] = (DCTELEM)
RIGHT_SHIFT(tmp0 + MULTIPLY(tmp10, FIX_0_765366865), /* c2-c6 */
CONST_BITS-PASS1_BITS-3);
dataptr[3] = (DCTELEM)
RIGHT_SHIFT(tmp0 - MULTIPLY(tmp11, FIX_1_847759065), /* c2+c6 */
CONST_BITS-PASS1_BITS-3);
/* Row 1 */
elemptr = sample_data[1] + start_col;
dataptr += DCTSIZE; /* advance pointer to next row */
}
/* Even part */
tmp4 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[3]);
tmp5 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[2]);
tmp10 = tmp4 + tmp5;
tmp12 = tmp4 - tmp5;
/* Odd part */
z2 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[3]);
z3 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[2]);
z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */
tmp11 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */
tmp13 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */
/* Pass 2: process columns.
* We remove the PASS1_BITS scaling, but leave the results scaled up
* by an overall factor of 8.
* We leave the results scaled up by an overall factor of 8.
* We must also scale the output by (8/4)*(8/2) = 2**3.
*/
dataptr = data;
for (ctr = 0; ctr < 4; ctr++) {
/* Even part */
/* Column 0 */
/* Apply unsigned->signed conversion. */
data[DCTSIZE*0] = (tmp0 + tmp10 - 8 * CENTERJSAMPLE) << 3;
data[DCTSIZE*1] = (tmp0 - tmp10) << 3;
/* Add fudge factor here for final descale. */
tmp0 = dataptr[DCTSIZE*0] + (ONE << (PASS1_BITS-1));
tmp1 = dataptr[DCTSIZE*1];
/* Column 1 */
data[DCTSIZE*0+1] = (DCTELEM) RIGHT_SHIFT(tmp1 + tmp11, CONST_BITS-3);
data[DCTSIZE*1+1] = (DCTELEM) RIGHT_SHIFT(tmp1 - tmp11, CONST_BITS-3);
dataptr[DCTSIZE*0] = (DCTELEM) RIGHT_SHIFT(tmp0 + tmp1, PASS1_BITS);
/* Column 2 */
data[DCTSIZE*0+2] = (tmp2 + tmp12) << 3;
data[DCTSIZE*1+2] = (tmp2 - tmp12) << 3;
/* Odd part */
dataptr[DCTSIZE*1] = (DCTELEM) RIGHT_SHIFT(tmp0 - tmp1, PASS1_BITS);
dataptr++; /* advance pointer to next column */
}
/* Column 3 */
data[DCTSIZE*0+3] = (DCTELEM) RIGHT_SHIFT(tmp3 + tmp13, CONST_BITS-3);
data[DCTSIZE*1+3] = (DCTELEM) RIGHT_SHIFT(tmp3 - tmp13, CONST_BITS-3);
}
@@ -4312,7 +4318,6 @@ jpeg_fdct_2x4 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
/* Pass 1: process rows.
* Note results are scaled up by sqrt(8) compared to a true DCT.
* We must also scale the output by (8/2)*(8/4) = 2**3, which we add here.
*/
dataptr = data;
@@ -4325,17 +4330,18 @@ jpeg_fdct_2x4 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
tmp1 = GETJSAMPLE(elemptr[1]);
/* Apply unsigned->signed conversion. */
dataptr[0] = (DCTELEM) ((tmp0 + tmp1 - 2 * CENTERJSAMPLE) << 3);
dataptr[0] = (DCTELEM) (tmp0 + tmp1 - 2 * CENTERJSAMPLE);
/* Odd part */
dataptr[1] = (DCTELEM) ((tmp0 - tmp1) << 3);
dataptr[1] = (DCTELEM) (tmp0 - tmp1);
dataptr += DCTSIZE; /* advance pointer to next row */
}
/* Pass 2: process columns.
* We leave the results scaled up by an overall factor of 8.
* We must also scale the output by (8/2)*(8/4) = 2**3.
* 4-point FDCT kernel,
* cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point FDCT].
*/
@@ -4350,21 +4356,21 @@ jpeg_fdct_2x4 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
tmp10 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*3];
tmp11 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*2];
dataptr[DCTSIZE*0] = (DCTELEM) (tmp0 + tmp1);
dataptr[DCTSIZE*2] = (DCTELEM) (tmp0 - tmp1);
dataptr[DCTSIZE*0] = (DCTELEM) ((tmp0 + tmp1) << 3);
dataptr[DCTSIZE*2] = (DCTELEM) ((tmp0 - tmp1) << 3);
/* Odd part */
tmp0 = MULTIPLY(tmp10 + tmp11, FIX_0_541196100); /* c6 */
/* Add fudge factor here for final descale. */
tmp0 += ONE << (CONST_BITS-1);
tmp0 += ONE << (CONST_BITS-3-1);
dataptr[DCTSIZE*1] = (DCTELEM)
RIGHT_SHIFT(tmp0 + MULTIPLY(tmp10, FIX_0_765366865), /* c2-c6 */
CONST_BITS);
CONST_BITS-3);
dataptr[DCTSIZE*3] = (DCTELEM)
RIGHT_SHIFT(tmp0 - MULTIPLY(tmp11, FIX_1_847759065), /* c2+c6 */
CONST_BITS);
CONST_BITS-3);
dataptr++; /* advance pointer to next column */
}
+6 -6
View File
@@ -2,7 +2,7 @@
* jidctint.c
*
* Copyright (C) 1991-1998, Thomas G. Lane.
* Modification developed 2002-2016 by Guido Vollbeding.
* Modification developed 2002-2018 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -1474,7 +1474,7 @@ jpeg_idct_10x10 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
/*
* Perform dequantization and inverse DCT on one block of coefficients,
* producing a 11x11 output block.
* producing an 11x11 output block.
*
* Optimized algorithm with 24 multiplications in the 1-D kernel.
* cK represents sqrt(2) * cos(K*pi/22).
@@ -3675,7 +3675,7 @@ jpeg_idct_10x5 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
/*
* Perform dequantization and inverse DCT on one block of coefficients,
* producing a 8x4 output block.
* producing an 8x4 output block.
*
* 4-point IDCT in pass 1 (columns), 8-point in pass 2 (rows).
*/
@@ -3835,7 +3835,7 @@ jpeg_idct_8x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
/*
* Perform dequantization and inverse DCT on one block of coefficients,
* producing a reduced-size 6x3 output block.
* producing a 6x3 output block.
*
* 3-point IDCT in pass 1 (columns), 6-point in pass 2 (rows).
*/
@@ -4082,7 +4082,7 @@ jpeg_idct_2x1 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
/*
* Perform dequantization and inverse DCT on one block of coefficients,
* producing a 8x16 output block.
* producing an 8x16 output block.
*
* 16-point IDCT in pass 1 (columns), 8-point in pass 2 (rows).
*/
@@ -5004,7 +5004,7 @@ jpeg_idct_4x8 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
/*
* Perform dequantization and inverse DCT on one block of coefficients,
* producing a reduced-size 3x6 output block.
* producing a 3x6 output block.
*
* 6-point IDCT in pass 1 (columns), 3-point in pass 2 (rows).
*/
+28 -32
View File
@@ -2,7 +2,7 @@
* jmemmgr.c
*
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2011-2012 by Guido Vollbeding.
* Modified 2011-2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -130,7 +130,7 @@ typedef struct {
jvirt_barray_ptr virt_barray_list;
/* This counts total space obtained from jpeg_get_small/large */
long total_space_allocated;
size_t total_space_allocated;
/* alloc_sarray and alloc_barray set this value for use by virtual
* array routines.
@@ -195,7 +195,7 @@ print_mem_stats (j_common_ptr cinfo, int pool_id)
* This is helpful because message parm array can't handle longs.
*/
fprintf(stderr, "Freeing pool %d, total space = %ld\n",
pool_id, mem->total_space_allocated);
pool_id, (long) mem->total_space_allocated);
for (lhdr_ptr = mem->large_list[pool_id]; lhdr_ptr != NULL;
lhdr_ptr = lhdr_ptr->hdr.next) {
@@ -260,11 +260,11 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
{
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
small_pool_ptr hdr_ptr, prev_hdr_ptr;
char * data_ptr;
size_t odd_bytes, min_request, slop;
char * data_ptr;
/* Check for unsatisfiable request (do now to ensure no overflow below) */
if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(small_pool_hdr)))
if (sizeofobject > (size_t) MAX_ALLOC_CHUNK - SIZEOF(small_pool_hdr))
out_of_memory(cinfo, 1); /* request exceeds malloc's ability */
/* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */
@@ -293,8 +293,8 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
else
slop = extra_pool_slop[pool_id];
/* Don't ask for more than MAX_ALLOC_CHUNK */
if (slop > (size_t) (MAX_ALLOC_CHUNK-min_request))
slop = (size_t) (MAX_ALLOC_CHUNK-min_request);
if (slop > (size_t) MAX_ALLOC_CHUNK - min_request)
slop = (size_t) MAX_ALLOC_CHUNK - min_request;
/* Try to get space, if fail reduce slop and try again */
for (;;) {
hdr_ptr = (small_pool_ptr) jpeg_get_small(cinfo, min_request + slop);
@@ -348,7 +348,7 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
size_t odd_bytes;
/* Check for unsatisfiable request (do now to ensure no overflow below) */
if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)))
if (sizeofobject > (size_t) MAX_ALLOC_CHUNK - SIZEOF(large_pool_hdr))
out_of_memory(cinfo, 3); /* request exceeds malloc's ability */
/* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */
@@ -404,7 +404,7 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
long ltemp;
/* Calculate max # of rows allowed in one allocation chunk */
ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) /
ltemp = (MAX_ALLOC_CHUNK - SIZEOF(large_pool_hdr)) /
((long) samplesperrow * SIZEOF(JSAMPLE));
if (ltemp <= 0)
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
@@ -416,15 +416,14 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
/* Get space for row pointers (small object) */
result = (JSAMPARRAY) alloc_small(cinfo, pool_id,
(size_t) (numrows * SIZEOF(JSAMPROW)));
(size_t) numrows * SIZEOF(JSAMPROW));
/* Get the rows themselves (large objects) */
currow = 0;
while (currow < numrows) {
rowsperchunk = MIN(rowsperchunk, numrows - currow);
workspace = (JSAMPROW) alloc_large(cinfo, pool_id,
(size_t) ((size_t) rowsperchunk * (size_t) samplesperrow
* SIZEOF(JSAMPLE)));
(size_t) rowsperchunk * (size_t) samplesperrow * SIZEOF(JSAMPLE));
for (i = rowsperchunk; i > 0; i--) {
result[currow++] = workspace;
workspace += samplesperrow;
@@ -452,7 +451,7 @@ alloc_barray (j_common_ptr cinfo, int pool_id,
long ltemp;
/* Calculate max # of rows allowed in one allocation chunk */
ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) /
ltemp = (MAX_ALLOC_CHUNK - SIZEOF(large_pool_hdr)) /
((long) blocksperrow * SIZEOF(JBLOCK));
if (ltemp <= 0)
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
@@ -464,15 +463,14 @@ alloc_barray (j_common_ptr cinfo, int pool_id,
/* Get space for row pointers (small object) */
result = (JBLOCKARRAY) alloc_small(cinfo, pool_id,
(size_t) (numrows * SIZEOF(JBLOCKROW)));
(size_t) numrows * SIZEOF(JBLOCKROW));
/* Get the rows themselves (large objects) */
currow = 0;
while (currow < numrows) {
rowsperchunk = MIN(rowsperchunk, numrows - currow);
workspace = (JBLOCKROW) alloc_large(cinfo, pool_id,
(size_t) ((size_t) rowsperchunk * (size_t) blocksperrow
* SIZEOF(JBLOCK)));
(size_t) rowsperchunk * (size_t) blocksperrow * SIZEOF(JBLOCK));
for (i = rowsperchunk; i > 0; i--) {
result[currow++] = workspace;
workspace += blocksperrow;
@@ -585,8 +583,8 @@ realize_virt_arrays (j_common_ptr cinfo)
/* Allocate the in-memory buffers for any unrealized virtual arrays */
{
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
long space_per_minheight, maximum_space, avail_mem;
long minheights, max_minheights;
long bytesperrow, space_per_minheight, maximum_space;
long avail_mem, minheights, max_minheights;
jvirt_sarray_ptr sptr;
jvirt_barray_ptr bptr;
@@ -598,18 +596,16 @@ realize_virt_arrays (j_common_ptr cinfo)
maximum_space = 0;
for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
if (sptr->mem_buffer == NULL) { /* if not realized yet */
space_per_minheight += (long) sptr->maxaccess *
(long) sptr->samplesperrow * SIZEOF(JSAMPLE);
maximum_space += (long) sptr->rows_in_array *
(long) sptr->samplesperrow * SIZEOF(JSAMPLE);
bytesperrow = (long) sptr->samplesperrow * SIZEOF(JSAMPLE);
space_per_minheight += (long) sptr->maxaccess * bytesperrow;
maximum_space += (long) sptr->rows_in_array * bytesperrow;
}
}
for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
if (bptr->mem_buffer == NULL) { /* if not realized yet */
space_per_minheight += (long) bptr->maxaccess *
(long) bptr->blocksperrow * SIZEOF(JBLOCK);
maximum_space += (long) bptr->rows_in_array *
(long) bptr->blocksperrow * SIZEOF(JBLOCK);
bytesperrow = (long) bptr->blocksperrow * SIZEOF(JBLOCK);
space_per_minheight += (long) bptr->maxaccess * bytesperrow;
maximum_space += (long) bptr->rows_in_array * bytesperrow;
}
}
@@ -618,7 +614,7 @@ realize_virt_arrays (j_common_ptr cinfo)
/* Determine amount of memory to actually use; this is system-dependent. */
avail_mem = jpeg_mem_available(cinfo, space_per_minheight, maximum_space,
mem->total_space_allocated);
(long) mem->total_space_allocated);
/* If the maximum space needed is available, make all the buffers full
* height; otherwise parcel it out with the same number of minheights
@@ -694,7 +690,7 @@ do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
long bytesperrow, file_offset, byte_count, rows, thisrow, i;
bytesperrow = (long) ptr->samplesperrow * SIZEOF(JSAMPLE);
file_offset = ptr->cur_start_row * bytesperrow;
file_offset = (long) ptr->cur_start_row * bytesperrow;
/* Loop to read or write each allocation chunk in mem_buffer */
for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) {
/* One chunk, but check for short chunk at end of buffer */
@@ -727,7 +723,7 @@ do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing)
long bytesperrow, file_offset, byte_count, rows, thisrow, i;
bytesperrow = (long) ptr->blocksperrow * SIZEOF(JBLOCK);
file_offset = ptr->cur_start_row * bytesperrow;
file_offset = (long) ptr->cur_start_row * bytesperrow;
/* Loop to read or write each allocation chunk in mem_buffer */
for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) {
/* One chunk, but check for short chunk at end of buffer */
@@ -771,7 +767,7 @@ access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
/* Make the desired part of the virtual array accessible */
if (start_row < ptr->cur_start_row ||
end_row > ptr->cur_start_row+ptr->rows_in_mem) {
end_row > ptr->cur_start_row + ptr->rows_in_mem) {
if (! ptr->b_s_open)
ERREXIT(cinfo, JERR_VIRTUAL_BUG);
/* Flush old buffer contents if necessary */
@@ -856,7 +852,7 @@ access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
/* Make the desired part of the virtual array accessible */
if (start_row < ptr->cur_start_row ||
end_row > ptr->cur_start_row+ptr->rows_in_mem) {
end_row > ptr->cur_start_row + ptr->rows_in_mem) {
if (! ptr->b_s_open)
ERREXIT(cinfo, JERR_VIRTUAL_BUG);
/* Flush old buffer contents if necessary */
@@ -1093,7 +1089,7 @@ jinit_memory_mgr (j_common_ptr cinfo)
mem->total_space_allocated = SIZEOF(my_memory_mgr);
/* Declare ourselves open for business */
cinfo->mem = & mem->pub;
cinfo->mem = &mem->pub;
/* Check for an environment variable JPEGMEM; if found, override the
* default max_memory setting from jpeg_mem_init. Note that the
+6 -2
View File
@@ -2,6 +2,7 @@
* jmemnobs.c
*
* Copyright (C) 1992-1996, Thomas G. Lane.
* Modified 2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -12,7 +13,7 @@
* This is very portable in the sense that it'll compile on almost anything,
* but you'd better have lots of main memory (or virtual memory) if you want
* to process big images.
* Note that the max_memory_to_use option is ignored by this implementation.
* Note that the max_memory_to_use option is respected by this implementation.
*/
#define JPEG_INTERNALS
@@ -66,13 +67,16 @@ jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)
/*
* This routine computes the total memory space available for allocation.
* Here we always say, "we got all you want bud!"
*/
GLOBAL(long)
jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,
long max_bytes_needed, long already_allocated)
{
if (cinfo->mem->max_memory_to_use)
return cinfo->mem->max_memory_to_use - already_allocated;
/* Here we say, "we got all you want bud!" */
return max_bytes_needed;
}
+8 -1
View File
@@ -2,7 +2,7 @@
* jpegint.h
*
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 1997-2017 by Guido Vollbeding.
* Modified 1997-2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -302,6 +302,13 @@ struct jpeg_color_quantizer {
#define RIGHT_SHIFT(x,shft) ((x) >> (shft))
#endif
/* Descale and correctly round an INT32 value that's scaled by N bits.
* We assume RIGHT_SHIFT rounds towards minus infinity, so adding
* the fudge factor is correct for either sign of X.
*/
#define DESCALE(x,n) RIGHT_SHIFT((x) + ((INT32) 1 << ((n)-1)), n)
/* Short forms of external names for systems with brain-damaged linkers. */
+7 -4
View File
@@ -2,7 +2,7 @@
* jpeglib.h
*
* Copyright (C) 1991-1998, Thomas G. Lane.
* Modified 2002-2017 by Guido Vollbeding.
* Modified 2002-2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -39,7 +39,7 @@ extern "C" {
#define JPEG_LIB_VERSION 90 /* Compatibility version 9.0 */
#define JPEG_LIB_VERSION_MAJOR 9
#define JPEG_LIB_VERSION_MINOR 3
#define JPEG_LIB_VERSION_MINOR 4
/* Various constants determining the sizes of things.
@@ -909,6 +909,7 @@ typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo));
#define jpeg_suppress_tables jSuppressTables
#define jpeg_alloc_quant_table jAlcQTable
#define jpeg_alloc_huff_table jAlcHTable
#define jpeg_std_huff_table jStdHTable
#define jpeg_start_compress jStrtCompress
#define jpeg_write_scanlines jWrtScanlines
#define jpeg_finish_compress jFinCompress
@@ -977,10 +978,10 @@ EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile));
/* Data source and destination managers: memory buffers. */
EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo,
unsigned char ** outbuffer,
unsigned long * outsize));
size_t * outsize));
EXTERN(void) jpeg_mem_src JPP((j_decompress_ptr cinfo,
const unsigned char * inbuffer,
unsigned long insize));
size_t insize));
/* Default parameter setup for compression */
EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo));
@@ -1005,6 +1006,8 @@ EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo,
boolean suppress));
EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo));
EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo));
EXTERN(JHUFF_TBL *) jpeg_std_huff_table JPP((j_common_ptr cinfo,
boolean isDC, int tblno));
/* Main entry points for compression */
EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo,
+3 -3
View File
@@ -2,7 +2,7 @@
* jutils.c
*
* Copyright (C) 1991-1996, Thomas G. Lane.
* Modified 2009-2011 by Guido Vollbeding.
* Modified 2009-2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -185,7 +185,7 @@ jcopy_sample_rows (JSAMPARRAY input_array, int source_row,
{
register JSAMPROW inptr, outptr;
#ifdef FMEMCOPY
register size_t count = (size_t) (num_cols * SIZEOF(JSAMPLE));
register size_t count = (size_t) num_cols * SIZEOF(JSAMPLE);
#else
register JDIMENSION count;
#endif
@@ -213,7 +213,7 @@ jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row,
/* Copy a row of coefficient blocks from one place to another. */
{
#ifdef FMEMCOPY
FMEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * SIZEOF(JCOEF)));
FMEMCOPY(output_row, input_row, (size_t) num_blocks * (DCTSIZE2 * SIZEOF(JCOEF)));
#else
register JCOEFPTR inptr, outptr;
register long count;
+3 -3
View File
@@ -1,7 +1,7 @@
/*
* jversion.h
*
* Copyright (C) 1991-2018, Thomas G. Lane, Guido Vollbeding.
* Copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -9,6 +9,6 @@
*/
#define JVERSION "9c 14-Jan-2018"
#define JVERSION "9d 12-Jan-2020"
#define JCOPYRIGHT "Copyright (C) 2018, Thomas G. Lane, Guido Vollbeding"
#define JCOPYRIGHT "Copyright (C) 2020, Thomas G. Lane, Guido Vollbeding"
Vendored Executable → Regular
View File
+3 -5
View File
@@ -22,7 +22,7 @@
# sqfu@openailab.com
#
SET(TENGINE_COMMIT_VERSION "2f3cd86217f3530c8e4a82f3ed5af14c7a4e3943")
SET(TENGINE_COMMIT_VERSION "8a4c58e0e05cd850f4bb0936a330edc86dc0e28c")
SET(OCV_TENGINE_DIR "${OpenCV_BINARY_DIR}/3rdparty/libtengine")
SET(OCV_TENGINE_SOURCE_PATH "${OCV_TENGINE_DIR}/Tengine-${TENGINE_COMMIT_VERSION}")
@@ -34,7 +34,7 @@ IF(EXISTS "${OCV_TENGINE_SOURCE_PATH}")
ELSE()
SET(OCV_TENGINE_FILENAME "${TENGINE_COMMIT_VERSION}.zip")#name2
SET(OCV_TENGINE_URL "https://github.com/OAID/Tengine/archive/") #url2
SET(tengine_md5sum 9124324b6e2b350012e46ae1db4bad7d) #md5sum2
SET(tengine_md5sum f51ca8f3963faeeff3f019a6f6edc206) #md5sum2
#MESSAGE(STATUS "**** TENGINE DOWNLOAD BEGIN ****")
ocv_download(FILENAME ${OCV_TENGINE_FILENAME}
@@ -69,7 +69,6 @@ if(BUILD_TENGINE)
elseif(${ANDROID_ABI} STREQUAL "arm64-v8a")
SET(CONFIG_ARCH_ARM64 ON)
endif()
SET(Tengine_LIB "tengine" CACHE INTERNAL "")
else()
# linux system
if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
@@ -77,7 +76,6 @@ if(BUILD_TENGINE)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) ## AARCH64
SET(CONFIG_ARCH_ARM64 ON)
endif()
SET(Tengine_LIB "tengine" CACHE INTERNAL "")
endif()
SET(BUILT_IN_OPENCV ON) ## set for tengine compile discern .
@@ -86,6 +84,6 @@ if(BUILD_TENGINE)
add_subdirectory("${OCV_TENGINE_SOURCE_PATH}" "${OCV_TENGINE_DIR}/build")
else()
message(WARNING "TENGINE: Missing 'CMakeLists.txt' in source code package: ${OCV_TENGINE_SOURCE_PATH}")
SET(HAVE_TENGINE 1)
endif()
SET(Tengine_LIB "tengine" CACHE INTERNAL "")
endif()
+1 -1
View File
@@ -63,7 +63,7 @@ Attribute::~Attribute () {}
namespace {
struct NameCompare: std::binary_function <const char *, const char *, bool>
struct NameCompare
{
bool
operator () (const char *x, const char *y) const
Vendored Executable → Regular
View File
View File
View File
View File
+54 -18
View File
@@ -225,7 +225,9 @@ class TextFormat::Parser::ParserImpl {
bool allow_unknown_enum,
bool allow_field_number,
bool allow_relaxed_whitespace,
bool allow_partial)
bool allow_partial,
int recursion_limit // backported from 3.8.0
)
: error_collector_(error_collector),
finder_(finder),
parse_info_tree_(parse_info_tree),
@@ -238,7 +240,9 @@ class TextFormat::Parser::ParserImpl {
allow_unknown_enum_(allow_unknown_enum),
allow_field_number_(allow_field_number),
allow_partial_(allow_partial),
had_errors_(false) {
had_errors_(false),
recursion_limit_(recursion_limit) // backported from 3.8.0
{
// For backwards-compatibility with proto1, we need to allow the 'f' suffix
// for floats.
tokenizer_.set_allow_f_after_float(true);
@@ -490,9 +494,9 @@ class TextFormat::Parser::ParserImpl {
if (TryConsume(":") && !LookingAt("{") && !LookingAt("<")) {
UnknownFieldSet* unknown_field = unknown_fields->AddGroup(unknown_fields->field_count());
unknown_field->AddLengthDelimited(0, field_name); // Add a field's name.
return SkipFieldValue(unknown_field);
return SkipFieldValue(unknown_field, recursion_limit_);
} else {
return SkipFieldMessage(unknown_fields);
return SkipFieldMessage(unknown_fields, recursion_limit_);
}
}
@@ -575,7 +579,14 @@ label_skip_parsing:
}
// Skips the next field including the field's name and value.
bool SkipField(UnknownFieldSet* unknown_fields) {
bool SkipField(UnknownFieldSet* unknown_fields, int recursion_limit) {
// OpenCV specific
if (--recursion_limit < 0) {
ReportError("Message is too deep (SkipField)");
return false;
}
string field_name;
if (TryConsume("[")) {
// Extension name.
@@ -594,9 +605,9 @@ label_skip_parsing:
if (TryConsume(":") && !LookingAt("{") && !LookingAt("<")) {
UnknownFieldSet* unknown_field = unknown_fields->AddGroup(unknown_fields->field_count());
unknown_field->AddLengthDelimited(0, field_name); // Add a field's name.
DO(SkipFieldValue(unknown_field));
DO(SkipFieldValue(unknown_field, recursion_limit));
} else {
DO(SkipFieldMessage(unknown_fields));
DO(SkipFieldMessage(unknown_fields, recursion_limit));
}
// For historical reasons, fields may optionally be separated by commas or
// semicolons.
@@ -608,6 +619,12 @@ label_skip_parsing:
const Reflection* reflection,
const FieldDescriptor* field) {
// backported from 3.8.0
if (--recursion_limit_ < 0) {
ReportError("Message is too deep");
return false;
}
// If the parse information tree is not NULL, create a nested one
// for the nested message.
ParseInfoTree* parent = parse_info_tree_;
@@ -624,6 +641,9 @@ label_skip_parsing:
delimiter));
}
// backported from 3.8.0
++recursion_limit_;
// Reset the parse information tree.
parse_info_tree_ = parent;
return true;
@@ -631,11 +651,17 @@ label_skip_parsing:
// Skips the whole body of a message including the beginning delimiter and
// the ending delimiter.
bool SkipFieldMessage(UnknownFieldSet* unknown_fields) {
bool SkipFieldMessage(UnknownFieldSet* unknown_fields, int recursion_limit) {
// OpenCV specific
if (--recursion_limit < 0) {
ReportError("Message is too deep (SkipFieldMessage)");
return false;
}
string delimiter;
DO(ConsumeMessageDelimiter(&delimiter));
while (!LookingAt(">") && !LookingAt("}")) {
DO(SkipField(unknown_fields));
DO(SkipField(unknown_fields, recursion_limit));
}
DO(Consume(delimiter));
return true;
@@ -775,7 +801,14 @@ label_skip_parsing:
return true;
}
bool SkipFieldValue(UnknownFieldSet* unknown_field) {
bool SkipFieldValue(UnknownFieldSet* unknown_field, int recursion_limit) {
// OpenCV specific
if (--recursion_limit < 0) {
ReportError("Message is too deep (SkipFieldValue)");
return false;
}
if (LookingAtType(io::Tokenizer::TYPE_STRING)) {
while (LookingAtType(io::Tokenizer::TYPE_STRING)) {
tokenizer_.Next();
@@ -785,9 +818,9 @@ label_skip_parsing:
if (TryConsume("[")) {
while (true) {
if (!LookingAt("{") && !LookingAt("<")) {
DO(SkipFieldValue(unknown_field));
DO(SkipFieldValue(unknown_field, recursion_limit));
} else {
DO(SkipFieldMessage(unknown_field));
DO(SkipFieldMessage(unknown_field, recursion_limit));
}
if (TryConsume("]")) {
break;
@@ -1156,6 +1189,7 @@ label_skip_parsing:
const bool allow_field_number_;
const bool allow_partial_;
bool had_errors_;
int recursion_limit_; // backported from 3.8.0
};
#undef DO
@@ -1306,17 +1340,19 @@ class TextFormat::Printer::TextGenerator
TextFormat::Finder::~Finder() {
}
TextFormat::Parser::Parser(bool allow_unknown_field)
TextFormat::Parser::Parser()
: error_collector_(NULL),
finder_(NULL),
parse_info_tree_(NULL),
allow_partial_(false),
allow_case_insensitive_field_(false),
allow_unknown_field_(allow_unknown_field),
allow_unknown_field_(false),
allow_unknown_enum_(false),
allow_field_number_(false),
allow_relaxed_whitespace_(false),
allow_singular_overwrites_(false) {
allow_singular_overwrites_(false),
recursion_limit_(std::numeric_limits<int>::max())
{
}
TextFormat::Parser::~Parser() {}
@@ -1335,7 +1371,7 @@ bool TextFormat::Parser::Parse(io::ZeroCopyInputStream* input,
overwrites_policy,
allow_case_insensitive_field_, allow_unknown_field_,
allow_unknown_enum_, allow_field_number_,
allow_relaxed_whitespace_, allow_partial_);
allow_relaxed_whitespace_, allow_partial_, recursion_limit_);
return MergeUsingImpl(input, output, &parser);
}
@@ -1353,7 +1389,7 @@ bool TextFormat::Parser::Merge(io::ZeroCopyInputStream* input,
ParserImpl::ALLOW_SINGULAR_OVERWRITES,
allow_case_insensitive_field_, allow_unknown_field_,
allow_unknown_enum_, allow_field_number_,
allow_relaxed_whitespace_, allow_partial_);
allow_relaxed_whitespace_, allow_partial_, recursion_limit_);
return MergeUsingImpl(input, output, &parser);
}
@@ -1388,7 +1424,7 @@ bool TextFormat::Parser::ParseFieldValueFromString(
ParserImpl::ALLOW_SINGULAR_OVERWRITES,
allow_case_insensitive_field_, allow_unknown_field_,
allow_unknown_enum_, allow_field_number_,
allow_relaxed_whitespace_, allow_partial_);
allow_relaxed_whitespace_, allow_partial_, recursion_limit_);
return parser.ParseField(field, output);
}
+16 -1
View File
@@ -457,7 +457,7 @@ class LIBPROTOBUF_EXPORT TextFormat {
// For more control over parsing, use this class.
class LIBPROTOBUF_EXPORT Parser {
public:
Parser(bool allow_unknown_field = false);
Parser();
~Parser();
// Like TextFormat::Parse().
@@ -508,10 +508,24 @@ class LIBPROTOBUF_EXPORT TextFormat {
Message* output);
// backported from 3.8.0
// When an unknown field is met, parsing will fail if this option is set
// to false(the default). If true, unknown fields will be ignored and
// a warning message will be generated.
// Please aware that set this option true may hide some errors (e.g.
// spelling error on field name). Avoid to use this option if possible.
void AllowUnknownField(bool allow) { allow_unknown_field_ = allow; }
void AllowFieldNumber(bool allow) {
allow_field_number_ = allow;
}
// backported from 3.8.0
// Sets maximum recursion depth which parser can use. This is effectively
// the maximum allowed nesting of proto messages.
void SetRecursionLimit(int limit) { recursion_limit_ = limit; }
private:
// Forward declaration of an internal class used to parse text
// representations (see text_format.cc for implementation).
@@ -533,6 +547,7 @@ class LIBPROTOBUF_EXPORT TextFormat {
bool allow_field_number_;
bool allow_relaxed_whitespace_;
bool allow_singular_overwrites_;
int recursion_limit_; // backported from 3.8.0
};
+2 -1
View File
@@ -32,8 +32,10 @@
#define QUIRC_PERSPECTIVE_PARAMS 8
#if QUIRC_MAX_REGIONS < UINT8_MAX
#define QUIRC_PIXEL_ALIAS_IMAGE 1
typedef uint8_t quirc_pixel_t;
#elif QUIRC_MAX_REGIONS < UINT16_MAX
#define QUIRC_PIXEL_ALIAS_IMAGE 0
typedef uint16_t quirc_pixel_t;
#else
#error "QUIRC_MAX_REGIONS > 65534 is not supported"
@@ -77,7 +79,6 @@ struct quirc_grid {
struct quirc {
uint8_t *image;
quirc_pixel_t *pixels;
int *row_average; /* used by threshold() */
int w;
int h;
+1 -1
View File
@@ -874,7 +874,7 @@ static quirc_decode_error_t decode_payload(struct quirc_data *data,
done:
/* Add nul terminator to all payloads */
if ((unsigned)data->payload_len >= sizeof(data->payload))
if (data->payload_len >= (int) sizeof(data->payload))
data->payload_len--;
data->payload[data->payload_len] = 0;
+10 -19
View File
@@ -27,10 +27,7 @@ struct quirc *quirc_new(void)
{
struct quirc *q = malloc(sizeof(*q));
if (!q)
return NULL;
memset(q, 0, sizeof(*q));
memset(q, 0, sizeof(*q));
return q;
}
@@ -39,9 +36,8 @@ void quirc_destroy(struct quirc *q)
free(q->image);
/* q->pixels may alias q->image when their type representation is of the
same size, so we need to be careful here to avoid a double free */
if (sizeof(*q->image) != sizeof(*q->pixels))
if (!QUIRC_PIXEL_ALIAS_IMAGE)
free(q->pixels);
free(q->row_average);
free(q);
}
@@ -49,7 +45,6 @@ int quirc_resize(struct quirc *q, int w, int h)
{
uint8_t *image = NULL;
quirc_pixel_t *pixels = NULL;
int *row_average = NULL;
/*
* XXX: w and h should be size_t (or at least unsigned) as negatives
@@ -82,35 +77,27 @@ int quirc_resize(struct quirc *q, int w, int h)
(void)memcpy(image, q->image, min);
/* alloc a new buffer for q->pixels if needed */
if (sizeof(*q->image) != sizeof(*q->pixels)) {
if (!QUIRC_PIXEL_ALIAS_IMAGE) {
pixels = calloc(newdim, sizeof(quirc_pixel_t));
if (!pixels)
goto fail;
}
/* alloc a new buffer for q->row_average */
row_average = calloc(w, sizeof(int));
if (!row_average)
goto fail;
/* alloc succeeded, update `q` with the new size and buffers */
q->w = w;
q->h = h;
free(q->image);
q->image = image;
if (sizeof(*q->image) != sizeof(*q->pixels)) {
if (!QUIRC_PIXEL_ALIAS_IMAGE) {
free(q->pixels);
q->pixels = pixels;
}
free(q->row_average);
q->row_average = row_average;
return 0;
/* NOTREACHED */
fail:
free(image);
free(pixels);
free(row_average);
return -1;
}
@@ -133,6 +120,10 @@ static const char *const error_table[] = {
const char *quirc_strerror(quirc_decode_error_t err)
{
if ((int)err < 8) { return error_table[err]; }
else { return "Unknown error"; }
if ((int) err >= 0) {
if ((unsigned long) err < (unsigned long) (sizeof(error_table) / sizeof(error_table[0])))
return error_table[err];
}
return "Unknown error";
}
+1 -10
View File
@@ -17,16 +17,7 @@
#include <quirc_internal.h>
const struct quirc_version_info quirc_version_db[QUIRC_MAX_VERSION + 1] = {
{ /* 0 */
.data_bytes = 0,
.apat = {0},
.ecc = {
{.bs = 0, .dw = 0, .ns = 0},
{.bs = 0, .dw = 0, .ns = 0},
{.bs = 0, .dw = 0, .ns = 0},
{.bs = 0, .dw = 0, .ns = 0}
}
},
{0},
{ /* Version 1 */
.data_bytes = 26,
.apat = {0},
+2 -2
View File
@@ -5,8 +5,8 @@ if (WIN32 AND NOT ARM)
message(FATAL_ERROR "BUILD_TBB option supports Windows on ARM only!\nUse regular official TBB build instead of the BUILD_TBB option!")
endif()
ocv_update(OPENCV_TBB_RELEASE "v2020.1")
ocv_update(OPENCV_TBB_RELEASE_MD5 "734f335d06ee80a7d4a20cc0da734c59")
ocv_update(OPENCV_TBB_RELEASE "v2020.2")
ocv_update(OPENCV_TBB_RELEASE_MD5 "5af6f6c2a24c2043e62e47205e273b1f")
ocv_update(OPENCV_TBB_FILENAME "${OPENCV_TBB_RELEASE}.tar.gz")
string(REGEX REPLACE "^v" "" OPENCV_TBB_RELEASE_ "${OPENCV_TBB_RELEASE}")
#ocv_update(OPENCV_TBB_SUBDIR ...)
+7 -2
View File
@@ -463,6 +463,7 @@ OCV_OPTION(BUILD_JAVA "Enable Java support"
# OpenCV installation options
# ===================================================
OCV_OPTION(INSTALL_CREATE_DISTRIB "Change install rules to build the distribution package" OFF )
OCV_OPTION(INSTALL_BIN_EXAMPLES "Install prebuilt examples" WIN32 IF BUILD_EXAMPLES)
OCV_OPTION(INSTALL_C_EXAMPLES "Install C examples" OFF )
OCV_OPTION(INSTALL_PYTHON_EXAMPLES "Install Python examples" OFF )
OCV_OPTION(INSTALL_ANDROID_EXAMPLES "Install Android examples" OFF IF ANDROID )
@@ -971,11 +972,11 @@ endif()
# for UNIX it does not make sense as LICENSE and readme will be part of the package automatically
if(ANDROID OR NOT UNIX)
install(FILES ${OPENCV_LICENSE_FILE}
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
DESTINATION ./ COMPONENT libs)
if(OPENCV_README_FILE)
install(FILES ${OPENCV_README_FILE}
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
DESTINATION ./ COMPONENT libs)
endif()
endif()
@@ -1652,6 +1653,10 @@ if(ENABLE_CONFIG_VERIFICATION)
ocv_verify_config()
endif()
if(HAVE_CUDA AND COMMAND CUDA_BUILD_CLEAN_TARGET)
CUDA_BUILD_CLEAN_TARGET()
endif()
ocv_cmake_hook(POST_FINALIZE)
# ----------------------------------------------------------------------------
+3 -1
View File
@@ -189,7 +189,6 @@ if(CV_GCC OR CV_CLANG)
# Profiling?
if(ENABLE_PROFILING)
add_extra_compiler_option("-pg -g")
# turn off incompatible options
foreach(flags CMAKE_CXX_FLAGS CMAKE_C_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG
OPENCV_EXTRA_FLAGS_RELEASE OPENCV_EXTRA_FLAGS_DEBUG OPENCV_EXTRA_C_FLAGS OPENCV_EXTRA_CXX_FLAGS)
@@ -197,6 +196,9 @@ if(CV_GCC OR CV_CLANG)
string(REPLACE "-ffunction-sections" "" ${flags} "${${flags}}")
string(REPLACE "-fdata-sections" "" ${flags} "${${flags}}")
endforeach()
# -pg should be placed both in the linker and in the compiler settings
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
add_extra_compiler_option("-pg -g")
else()
if(MSVC)
# TODO: Clang/C2 is not supported
+243 -35
View File
@@ -1,13 +1,14 @@
if(WIN32 AND NOT MSVC)
if((WIN32 AND NOT MSVC) OR OPENCV_CMAKE_FORCE_CUDA)
message(STATUS "CUDA compilation is disabled (due to only Visual Studio compiler supported on your platform).")
return()
endif()
if(NOT UNIX AND CV_CLANG)
if((NOT UNIX AND CV_CLANG) OR OPENCV_CMAKE_FORCE_CUDA)
message(STATUS "CUDA compilation is disabled (due to Clang unsupported on your platform).")
return()
endif()
#set(OPENCV_CMAKE_CUDA_DEBUG 1)
if(((NOT CMAKE_VERSION VERSION_LESS "3.9.0") # requires https://gitlab.kitware.com/cmake/cmake/merge_requests/663
OR OPENCV_CUDA_FORCE_EXTERNAL_CMAKE_MODULE)
@@ -28,6 +29,11 @@ endif()
if(CUDA_FOUND)
set(HAVE_CUDA 1)
if(NOT CUDA_VERSION VERSION_LESS 11.0)
# CUDA 11.0 removes nppicom
ocv_list_filterout(CUDA_nppi_LIBRARY "nppicom")
ocv_list_filterout(CUDA_npp_LIBRARY "nppicom")
endif()
if(WITH_CUFFT)
set(HAVE_CUFFT 1)
@@ -38,11 +44,31 @@ if(CUDA_FOUND)
endif()
if(WITH_NVCUVID)
macro(ocv_cuda_SEARCH_NVCUVID_HEADER _filename _result)
# place header file under CUDA_TOOLKIT_TARGET_DIR or CUDA_TOOLKIT_ROOT_DIR
find_path(_header_result
${_filename}
PATHS "${CUDA_TOOLKIT_TARGET_DIR}" "${CUDA_TOOLKIT_ROOT_DIR}"
ENV CUDA_PATH
ENV CUDA_INC_PATH
PATH_SUFFIXES include
NO_DEFAULT_PATH
)
if("x${_header_result}" STREQUAL "x_header_result-NOTFOUND")
set(${_result} 0)
else()
set(${_result} 1)
endif()
unset(_header_result CACHE)
endmacro()
ocv_cuda_SEARCH_NVCUVID_HEADER("nvcuvid.h" HAVE_NVCUVID_HEADER)
ocv_cuda_SEARCH_NVCUVID_HEADER("dynlink_nvcuvid.h" HAVE_DYNLINK_NVCUVID_HEADER)
find_cuda_helper_libs(nvcuvid)
if(WIN32)
find_cuda_helper_libs(nvcuvenc)
endif()
if(CUDA_nvcuvid_LIBRARY)
if(CUDA_nvcuvid_LIBRARY AND (${HAVE_NVCUVID_HEADER} OR ${HAVE_DYNLINK_NVCUVID_HEADER}))
# make sure to have both header and library before enabling
set(HAVE_NVCUVID 1)
endif()
if(CUDA_nvcuvenc_LIBRARY)
@@ -52,7 +78,19 @@ if(CUDA_FOUND)
message(STATUS "CUDA detected: " ${CUDA_VERSION})
set(_generations "Fermi" "Kepler" "Maxwell" "Pascal" "Volta" "Turing")
OCV_OPTION(CUDA_ENABLE_DEPRECATED_GENERATION "Enable deprecated generations in the list" OFF)
set(_generations "Maxwell" "Pascal" "Volta" "Turing" "Ampere")
if(CUDA_ENABLE_DEPRECATED_GENERATION)
set(_generations "Fermi" "${_generations}")
set(_generations "Kepler" "${_generations}")
endif()
set(_arch_fermi "2.0")
set(_arch_kepler "3.0;3.5;3.7")
set(_arch_maxwell "5.0;5.2")
set(_arch_pascal "6.0;6.1")
set(_arch_volta "7.0")
set(_arch_turing "7.5")
set(_arch_ampere "8.0;8.6")
if(NOT CMAKE_CROSSCOMPILING)
list(APPEND _generations "Auto")
endif()
@@ -70,30 +108,127 @@ if(CUDA_FOUND)
unset(CUDA_ARCH_PTX CACHE)
endif()
if(OPENCV_CUDA_DETECTION_NVCC_FLAGS MATCHES "-ccbin")
# already specified by user
elseif(CUDA_HOST_COMPILER AND EXISTS "${CUDA_HOST_COMPILER}")
get_filename_component(c_compiler_realpath "${CMAKE_C_COMPILER}" REALPATH)
# C compiler doesn't work with --run option, forcing C++ compiler instead
if(CUDA_HOST_COMPILER STREQUAL c_compiler_realpath OR CUDA_HOST_COMPILER STREQUAL CMAKE_C_COMPILER)
if(DEFINED CMAKE_CXX_COMPILER)
get_filename_component(cxx_compiler_realpath "${CMAKE_CXX_COMPILER}" REALPATH)
LIST(APPEND OPENCV_CUDA_DETECTION_NVCC_FLAGS -ccbin "${cxx_compiler_realpath}")
else()
message(STATUS "CUDA: CMAKE_CXX_COMPILER is not available. You may need to specify CUDA_HOST_COMPILER.")
endif()
else()
LIST(APPEND OPENCV_CUDA_DETECTION_NVCC_FLAGS -ccbin "${CUDA_HOST_COMPILER}")
endif()
elseif(WIN32 AND CMAKE_LINKER) # Workaround for VS cl.exe not being in the env. path
get_filename_component(host_compiler_bindir ${CMAKE_LINKER} DIRECTORY)
LIST(APPEND OPENCV_CUDA_DETECTION_NVCC_FLAGS -ccbin "${host_compiler_bindir}")
else()
if(CUDA_HOST_COMPILER)
message(STATUS "CUDA: CUDA_HOST_COMPILER='${CUDA_HOST_COMPILER}' is not valid, autodetection may not work. Specify OPENCV_CUDA_DETECTION_NVCC_FLAGS with -ccbin option for fix that")
endif()
endif()
macro(ocv_filter_available_architecture result_list)
set(__cache_key_check "${ARGN} : ${CUDA_NVCC_EXECUTABLE} ${OPENCV_CUDA_DETECTION_NVCC_FLAGS}")
if(DEFINED OPENCV_CACHE_CUDA_SUPPORTED_CC AND OPENCV_CACHE_CUDA_SUPPORTED_CC_check STREQUAL __cache_key_check)
set(${result_list} "${OPENCV_CACHE_CUDA_SUPPORTED_CC}")
else()
set(CC_LIST ${ARGN})
foreach(target_arch ${CC_LIST})
string(REPLACE "." "" target_arch_short "${target_arch}")
set(NVCC_OPTION "-gencode;arch=compute_${target_arch_short},code=sm_${target_arch_short}")
set(_cmd "${CUDA_NVCC_EXECUTABLE}" ${OPENCV_CUDA_DETECTION_NVCC_FLAGS} ${NVCC_OPTION} "${OpenCV_SOURCE_DIR}/cmake/checks/OpenCVDetectCudaArch.cu" --compile)
execute_process(
COMMAND ${_cmd}
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/"
RESULT_VARIABLE _nvcc_res
OUTPUT_VARIABLE _nvcc_out
ERROR_VARIABLE _nvcc_err
#ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(OPENCV_CMAKE_CUDA_DEBUG)
message(WARNING "COMMAND: ${_cmd}")
message(STATUS "Result: ${_nvcc_res}")
message(STATUS "Out: ${_nvcc_out}")
message(STATUS "Err: ${_nvcc_err}")
endif()
if(_nvcc_res EQUAL 0)
LIST(APPEND ${result_list} "${target_arch}")
endif()
endforeach()
string(STRIP "${${result_list}}" ${result_list})
if(" ${${result_list}}" STREQUAL " ")
message(WARNING "CUDA: Autodetection arch list is empty. Please enable OPENCV_CMAKE_CUDA_DEBUG=1 and check/specify OPENCV_CUDA_DETECTION_NVCC_FLAGS variable")
endif()
# cache detected values
set(OPENCV_CACHE_CUDA_SUPPORTED_CC ${${result_list}} CACHE INTERNAL "")
set(OPENCV_CACHE_CUDA_SUPPORTED_CC_check "${__cache_key_check}" CACHE INTERNAL "")
endif()
endmacro()
macro(ocv_detect_native_cuda_arch status output)
set(OPENCV_CUDA_DETECT_ARCHS_COMMAND "${CUDA_NVCC_EXECUTABLE}" ${OPENCV_CUDA_DETECTION_NVCC_FLAGS} "${OpenCV_SOURCE_DIR}/cmake/checks/OpenCVDetectCudaArch.cu" "--run")
set(__cache_key_check "${OPENCV_CUDA_DETECT_ARCHS_COMMAND}")
if(DEFINED OPENCV_CACHE_CUDA_ACTIVE_CC AND OPENCV_CACHE_CUDA_ACTIVE_CC_check STREQUAL __cache_key_check)
set(${output} "${OPENCV_CACHE_CUDA_ACTIVE_CC}")
set(${status} 0)
else()
execute_process(
COMMAND ${OPENCV_CUDA_DETECT_ARCHS_COMMAND}
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/"
RESULT_VARIABLE ${status}
OUTPUT_VARIABLE _nvcc_out
ERROR_VARIABLE _nvcc_err
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(OPENCV_CMAKE_CUDA_DEBUG)
message(WARNING "COMMAND: ${OPENCV_CUDA_DETECT_ARCHS_COMMAND}")
message(STATUS "Result: ${${status}}")
message(STATUS "Out: ${_nvcc_out}")
message(STATUS "Err: ${_nvcc_err}")
endif()
string(REGEX REPLACE ".*\n" "" ${output} "${_nvcc_out}") #Strip leading warning messages, if any
if(${status} EQUAL 0)
# cache detected values
set(OPENCV_CACHE_CUDA_ACTIVE_CC ${${output}} CACHE INTERNAL "")
set(OPENCV_CACHE_CUDA_ACTIVE_CC_check "${__cache_key_check}" CACHE INTERNAL "")
endif()
endif()
endmacro()
set(__cuda_arch_ptx "")
if(CUDA_GENERATION STREQUAL "Fermi")
set(__cuda_arch_bin "2.0")
set(__cuda_arch_bin ${_arch_fermi})
elseif(CUDA_GENERATION STREQUAL "Kepler")
set(__cuda_arch_bin "3.0 3.5 3.7")
set(__cuda_arch_bin ${_arch_kepler})
elseif(CUDA_GENERATION STREQUAL "Maxwell")
set(__cuda_arch_bin "5.0 5.2")
set(__cuda_arch_bin ${_arch_maxwell})
elseif(CUDA_GENERATION STREQUAL "Pascal")
set(__cuda_arch_bin "6.0 6.1")
set(__cuda_arch_bin ${_arch_pascal})
elseif(CUDA_GENERATION STREQUAL "Volta")
set(__cuda_arch_bin "7.0")
set(__cuda_arch_bin ${_arch_volta})
elseif(CUDA_GENERATION STREQUAL "Turing")
set(__cuda_arch_bin "7.5")
set(__cuda_arch_bin ${_arch_turing})
elseif(CUDA_GENERATION STREQUAL "Ampere")
set(__cuda_arch_bin ${_arch_ampere})
elseif(CUDA_GENERATION STREQUAL "Auto")
execute_process( COMMAND "${CUDA_NVCC_EXECUTABLE}" ${CUDA_NVCC_FLAGS} "${OpenCV_SOURCE_DIR}/cmake/checks/OpenCVDetectCudaArch.cu" "--run"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/"
RESULT_VARIABLE _nvcc_res OUTPUT_VARIABLE _nvcc_out
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
ocv_detect_native_cuda_arch(_nvcc_res _nvcc_out)
if(NOT _nvcc_res EQUAL 0)
message(STATUS "Automatic detection of CUDA generation failed. Going to build for all known architectures.")
else()
set(__cuda_arch_bin "${_nvcc_out}")
string(REPLACE "2.1" "2.1(2.0)" __cuda_arch_bin "${__cuda_arch_bin}")
string(REGEX MATCHALL "[0-9]+\\.[0-9]" __cuda_arch_bin "${_nvcc_out}")
endif()
elseif(CUDA_ARCH_BIN)
message(STATUS "CUDA: Using CUDA_ARCH_BIN=${CUDA_ARCH_BIN}")
set(__cuda_arch_bin ${CUDA_ARCH_BIN})
endif()
if(NOT DEFINED __cuda_arch_bin)
@@ -101,26 +236,34 @@ if(CUDA_FOUND)
set(__cuda_arch_bin "3.2")
set(__cuda_arch_ptx "")
elseif(AARCH64)
execute_process( COMMAND "${CUDA_NVCC_EXECUTABLE}" ${CUDA_NVCC_FLAGS} "${OpenCV_SOURCE_DIR}/cmake/checks/OpenCVDetectCudaArch.cu" "--run"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/"
RESULT_VARIABLE _nvcc_res OUTPUT_VARIABLE _nvcc_out
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT CMAKE_CROSSCOMPILING)
ocv_detect_native_cuda_arch(_nvcc_res _nvcc_out)
else()
set(_nvcc_res -1) # emulate error, see below
endif()
if(NOT _nvcc_res EQUAL 0)
message(STATUS "Automatic detection of CUDA generation failed. Going to build for all known architectures.")
set(__cuda_arch_bin "5.3 6.2 7.2")
# TX1 (5.3) TX2 (6.2) Xavier (7.2) V100 (7.0)
ocv_filter_available_architecture(__cuda_arch_bin
5.3
6.2
7.2
7.0
)
else()
set(__cuda_arch_bin "${_nvcc_out}")
string(REPLACE "2.1" "2.1(2.0)" __cuda_arch_bin "${__cuda_arch_bin}")
endif()
set(__cuda_arch_ptx "")
else()
if(CUDA_VERSION VERSION_LESS "9.0")
set(__cuda_arch_bin "2.0 3.0 3.5 3.7 5.0 5.2 6.0 6.1")
elseif(CUDA_VERSION VERSION_LESS "10.0")
set(__cuda_arch_bin "3.0 3.5 3.7 5.0 5.2 6.0 6.1 7.0")
else()
set(__cuda_arch_bin "3.0 3.5 3.7 5.0 5.2 6.0 6.1 7.0 7.5")
endif()
ocv_filter_available_architecture(__cuda_arch_bin
${_arch_fermi}
${_arch_kepler}
${_arch_maxwell}
${_arch_pascal}
${_arch_volta}
${_arch_turing}
${_arch_ampere}
)
endif()
endif()
@@ -130,12 +273,14 @@ if(CUDA_FOUND)
string(REGEX REPLACE "\\." "" ARCH_BIN_NO_POINTS "${CUDA_ARCH_BIN}")
string(REGEX REPLACE "\\." "" ARCH_PTX_NO_POINTS "${CUDA_ARCH_PTX}")
# Ckeck if user specified 1.0 compute capability: we don't support it
string(REGEX MATCH "1.0" HAS_ARCH_10 "${CUDA_ARCH_BIN} ${CUDA_ARCH_PTX}")
set(CUDA_ARCH_BIN_OR_PTX_10 0)
if(NOT ${HAS_ARCH_10} STREQUAL "")
set(CUDA_ARCH_BIN_OR_PTX_10 1)
endif()
# Check if user specified 1.0/2.1 compute capability: we don't support it
macro(ocv_wipeout_deprecated_cc target_cc)
if(" ${CUDA_ARCH_BIN} ${CUDA_ARCH_PTX}" MATCHES " ${target_cc}")
message(SEND_ERROR "CUDA: ${target_cc} compute capability is not supported - exclude it from ARCH/PTX list and re-run CMake")
endif()
endmacro()
ocv_wipeout_deprecated_cc("1.0")
ocv_wipeout_deprecated_cc("2.1")
# NVCC flags to be set
set(NVCC_FLAGS_EXTRA "")
@@ -245,6 +390,16 @@ if(CUDA_FOUND)
if(UNIX OR APPLE)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler -fPIC)
if(
ENABLE_CXX11
AND NOT " ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_DEBUG} ${CUDA_NVCC_FLAGS}" MATCHES "-std="
)
if(CUDA_VERSION VERSION_LESS "11.0")
list(APPEND CUDA_NVCC_FLAGS "--std=c++11")
else()
list(APPEND CUDA_NVCC_FLAGS "--std=c++14")
endif()
endif()
endif()
if(APPLE)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler -fno-finite-math-only)
@@ -308,4 +463,57 @@ if(HAVE_CUDA)
set(CUDA_cufft_LIBRARY_ABS ${CUDA_cufft_LIBRARY})
ocv_convert_to_lib_name(CUDA_cufft_LIBRARY ${CUDA_cufft_LIBRARY})
endif()
if(CMAKE_GENERATOR MATCHES "Visual Studio"
AND NOT OPENCV_SKIP_CUDA_CMAKE_SUPPRESS_REGENERATION
)
message(STATUS "CUDA: MSVS generator is detected. Disabling CMake re-run checks (CMAKE_SUPPRESS_REGENERATION=ON). You need to run CMake manually if updates are required.")
set(CMAKE_SUPPRESS_REGENERATION ON)
endif()
endif()
# ----------------------------------------------------------------------------
# Add CUDA libraries (needed for apps/tools, samples)
# ----------------------------------------------------------------------------
if(HAVE_CUDA)
# details: https://github.com/NVIDIA/nvidia-docker/issues/775
if(" ${CUDA_CUDA_LIBRARY}" MATCHES "/stubs/libcuda.so" AND NOT OPENCV_SKIP_CUDA_STUB_WORKAROUND)
set(CUDA_STUB_ENABLED_LINK_WORKAROUND 1)
if(EXISTS "${CUDA_CUDA_LIBRARY}" AND NOT OPENCV_SKIP_CUDA_STUB_WORKAROUND_RPATH_LINK)
set(CUDA_STUB_TARGET_PATH "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/")
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${CUDA_CUDA_LIBRARY}" "${CUDA_STUB_TARGET_PATH}/libcuda.so.1"
RESULT_VARIABLE CUDA_STUB_SYMLINK_RESULT)
if(NOT CUDA_STUB_SYMLINK_RESULT EQUAL 0)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CUDA_CUDA_LIBRARY}" "${CUDA_STUB_TARGET_PATH}/libcuda.so.1"
RESULT_VARIABLE CUDA_STUB_COPY_RESULT)
if(NOT CUDA_STUB_COPY_RESULT EQUAL 0)
set(CUDA_STUB_ENABLED_LINK_WORKAROUND 0)
endif()
endif()
if(CUDA_STUB_ENABLED_LINK_WORKAROUND)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath-link,\"${CUDA_STUB_TARGET_PATH}\"")
endif()
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--allow-shlib-undefined")
endif()
if(NOT CUDA_STUB_ENABLED_LINK_WORKAROUND)
message(WARNING "CUDA: workaround for stubs/libcuda.so.1 is not applied")
endif()
endif()
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
if(HAVE_CUBLAS)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_cublas_LIBRARY})
endif()
if(HAVE_CUFFT)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_cufft_LIBRARY})
endif()
foreach(p ${CUDA_LIBS_PATH})
if(MSVC AND CMAKE_GENERATOR MATCHES "Ninja|JOM")
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CMAKE_LIBRARY_PATH_FLAG}"${p}")
else()
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CMAKE_LIBRARY_PATH_FLAG}${p})
endif()
endforeach()
endif()
+48 -12
View File
@@ -24,10 +24,33 @@ endif()
# =======================
macro(ocv_ie_find_extra_libraries find_prefix find_suffix)
file(GLOB libraries "${INF_ENGINE_LIB_DIRS}/${find_prefix}inference_engine*${find_suffix}")
foreach(full_path IN LISTS libraries)
get_filename_component(library "${full_path}" NAME_WE)
string(REPLACE "${find_prefix}" "" library "${library}")
if(library STREQUAL "inference_engine" OR library STREQUAL "inference_engined")
# skip
else()
add_library(${library} UNKNOWN IMPORTED)
set_target_properties(${library} PROPERTIES
IMPORTED_LOCATION "${full_path}")
list(APPEND custom_libraries ${library})
endif()
endforeach()
endmacro()
function(add_custom_ie_build _inc _lib _lib_rel _lib_dbg _msg)
if(NOT _inc OR NOT (_lib OR _lib_rel OR _lib_dbg))
return()
endif()
if(NOT _lib)
if(_lib_rel)
set(_lib "${_lib_rel}")
else()
set(_lib "${_lib_dbg}")
endif()
endif()
add_library(inference_engine UNKNOWN IMPORTED)
set_target_properties(inference_engine PROPERTIES
IMPORTED_LOCATION "${_lib}"
@@ -37,24 +60,31 @@ function(add_custom_ie_build _inc _lib _lib_rel _lib_dbg _msg)
)
set(custom_libraries "")
file(GLOB libraries "${INF_ENGINE_LIB_DIRS}/${CMAKE_SHARED_LIBRARY_PREFIX}inference_engine_*${CMAKE_SHARED_LIBRARY_SUFFIX}")
foreach(full_path IN LISTS libraries)
get_filename_component(library "${full_path}" NAME_WE)
string(REPLACE "${CMAKE_SHARED_LIBRARY_PREFIX}" "" library "${library}")
add_library(${library} UNKNOWN IMPORTED)
set_target_properties(${library} PROPERTIES
IMPORTED_LOCATION "${full_path}")
list(APPEND custom_libraries ${library})
set(__prefixes "${CMAKE_FIND_LIBRARY_PREFIXES}")
if(NOT __prefixes)
set(__prefixes "_empty_")
endif()
foreach(find_prefix ${__prefixes})
if(find_prefix STREQUAL "_empty_") # foreach doesn't iterate over empty elements
set(find_prefix "")
endif()
foreach(find_suffix ${CMAKE_FIND_LIBRARY_SUFFIXES})
ocv_ie_find_extra_libraries("${find_prefix}" "${find_suffix}")
endforeach()
if(NOT CMAKE_FIND_LIBRARY_SUFFIXES)
ocv_ie_find_extra_libraries("${find_prefix}" "")
endif()
endforeach()
if(NOT INF_ENGINE_RELEASE VERSION_GREATER "2018050000")
find_library(INF_ENGINE_OMP_LIBRARY iomp5 PATHS "${INF_ENGINE_OMP_DIR}" NO_DEFAULT_PATH)
if(NOT INF_ENGINE_OMP_LIBRARY)
message(WARNING "OpenMP for IE have not been found. Set INF_ENGINE_OMP_DIR variable if you experience build errors.")
else()
set_target_properties(inference_engine PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES "${INF_ENGINE_OMP_LIBRARY}")
endif()
endif()
if(EXISTS "${INF_ENGINE_OMP_LIBRARY}")
set_target_properties(inference_engine PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES "${INF_ENGINE_OMP_LIBRARY}")
endif()
set(INF_ENGINE_VERSION "Unknown" CACHE STRING "")
set(INF_ENGINE_TARGET "inference_engine;${custom_libraries}" PARENT_SCOPE)
message(STATUS "Detected InferenceEngine: ${_msg}")
@@ -71,6 +101,9 @@ endif()
if(NOT INF_ENGINE_TARGET AND INF_ENGINE_LIB_DIRS AND INF_ENGINE_INCLUDE_DIRS)
find_path(ie_custom_inc "inference_engine.hpp" PATHS "${INF_ENGINE_INCLUDE_DIRS}" NO_DEFAULT_PATH)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
find_library(ie_custom_lib_dbg "inference_engined" PATHS "${INF_ENGINE_LIB_DIRS}" NO_DEFAULT_PATH) # Win32 and MacOSX
endif()
find_library(ie_custom_lib "inference_engine" PATHS "${INF_ENGINE_LIB_DIRS}" NO_DEFAULT_PATH)
find_library(ie_custom_lib_rel "inference_engine" PATHS "${INF_ENGINE_LIB_DIRS}/Release" NO_DEFAULT_PATH)
find_library(ie_custom_lib_dbg "inference_engine" PATHS "${INF_ENGINE_LIB_DIRS}/Debug" NO_DEFAULT_PATH)
@@ -89,6 +122,9 @@ if(NOT INF_ENGINE_TARGET AND _loc)
endif()
set(INF_ENGINE_PLATFORM "${INF_ENGINE_PLATFORM_DEFAULT}" CACHE STRING "InferenceEngine platform (library dir)")
find_path(ie_custom_env_inc "inference_engine.hpp" PATHS "${_loc}/deployment_tools/inference_engine/include" NO_DEFAULT_PATH)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
find_library(ie_custom_env_lib_dbg "inference_engined" PATHS "${_loc}/deployment_tools/inference_engine/lib/${INF_ENGINE_PLATFORM}/intel64" NO_DEFAULT_PATH)
endif()
find_library(ie_custom_env_lib "inference_engine" PATHS "${_loc}/deployment_tools/inference_engine/lib/${INF_ENGINE_PLATFORM}/intel64" NO_DEFAULT_PATH)
find_library(ie_custom_env_lib_rel "inference_engine" PATHS "${_loc}/deployment_tools/inference_engine/lib/intel64/Release" NO_DEFAULT_PATH)
find_library(ie_custom_env_lib_dbg "inference_engine" PATHS "${_loc}/deployment_tools/inference_engine/lib/intel64/Debug" NO_DEFAULT_PATH)
@@ -99,9 +135,9 @@ endif()
if(INF_ENGINE_TARGET)
if(NOT INF_ENGINE_RELEASE)
message(WARNING "InferenceEngine version has not been set, 2020.1 will be used by default. Set INF_ENGINE_RELEASE variable if you experience build errors.")
message(WARNING "InferenceEngine version has not been set, 2020.4 will be used by default. Set INF_ENGINE_RELEASE variable if you experience build errors.")
endif()
set(INF_ENGINE_RELEASE "2020010000" CACHE STRING "Force IE version, should be in form YYYYAABBCC (e.g. 2020.1.0.2 -> 2020010002)")
set(INF_ENGINE_RELEASE "2020040000" CACHE STRING "Force IE version, should be in form YYYYAABBCC (e.g. 2020.1.0.2 -> 2020010002)")
set_target_properties(${INF_ENGINE_TARGET} PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "HAVE_INF_ENGINE=1;INF_ENGINE_RELEASE=${INF_ENGINE_RELEASE}"
)
+13 -8
View File
@@ -1,17 +1,22 @@
# ----------------------------------------------------------------------------
# Uninstall target, for "make uninstall"
# ----------------------------------------------------------------------------
CONFIGURE_FILE(
"${OpenCV_SOURCE_DIR}/cmake/templates/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
@ONLY)
if(NOT TARGET uninstall) # avoid conflicts with parent projects
configure_file(
"${OpenCV_SOURCE_DIR}/cmake/templates/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
@ONLY
)
ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(uninstall PROPERTIES FOLDER "CMakeTargets")
add_custom_target(uninstall
COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
)
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(uninstall PROPERTIES FOLDER "CMakeTargets")
endif()
endif()
# ----------------------------------------------------------------------------
# target building all OpenCV modules
# ----------------------------------------------------------------------------
+2 -1
View File
@@ -148,7 +148,7 @@ macro(ipp_detect_version)
IMPORTED_LOCATION ${IPP_LIBRARY_DIR}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX}
)
list(APPEND IPP_LIBRARIES ipp${name})
if (NOT BUILD_SHARED_LIBS)
if (NOT BUILD_SHARED_LIBS AND (HAVE_IPP_ICV OR ";${OPENCV_INSTALL_EXTERNAL_DEPENDENCIES};" MATCHES ";ipp;"))
# CMake doesn't support "install(TARGETS ${IPP_PREFIX}${name} " command with imported targets
install(FILES ${IPP_LIBRARY_DIR}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX}
DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
@@ -252,6 +252,7 @@ if(NOT DEFINED IPPROOT)
else()
ocv_install_3rdparty_licenses(ippicv "${ICV_PACKAGE_ROOT}/EULA.txt")
endif()
ocv_install_3rdparty_licenses(ippicv "${ICV_PACKAGE_ROOT}/third-party-programs.txt")
endif()
file(TO_CMAKE_PATH "${IPPROOT}" __IPPROOT)
+5 -4
View File
@@ -108,12 +108,13 @@ macro(ippiw_setup PATH BUILD)
message(STATUS "found Intel IPP Integration Wrappers binaries: ${IW_VERSION_MAJOR}.${IW_VERSION_MINOR}.${IW_VERSION_UPDATE}")
message(STATUS "at: ${IPP_IW_PATH}")
add_library(ippiw STATIC IMPORTED)
set_target_properties(ippiw PROPERTIES
add_library(ipp_iw STATIC IMPORTED)
set_target_properties(ipp_iw PROPERTIES
IMPORTED_LINK_INTERFACE_LIBRARIES ""
IMPORTED_LOCATION "${FILE}"
)
if (NOT BUILD_SHARED_LIBS)
if (NOT BUILD_SHARED_LIBS AND ";${OPENCV_INSTALL_EXTERNAL_DEPENDENCIES};" MATCHES ";ipp;")
# CMake doesn't support "install(TARGETS ${name} ...)" command with imported targets
install(FILES "${FILE}"
DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
@@ -122,7 +123,7 @@ macro(ippiw_setup PATH BUILD)
endif()
set(IPP_IW_INCLUDES "${IPP_IW_PATH}/include")
set(IPP_IW_LIBRARIES ippiw)
set(IPP_IW_LIBRARIES ipp_iw)
set(HAVE_IPP_IW 1)
set(BUILD_IPP_IW 0)
+13 -7
View File
@@ -79,9 +79,10 @@ get_mkl_version(${MKL_INCLUDE_DIRS}/mkl_version.h)
#determine arch
if(CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8)
set(MKL_X64 1)
set(MKL_ARCH "intel64")
set(MKL_ARCH_LIST "intel64")
if(MSVC)
list(APPEND MKL_ARCH_LIST "win-x64")
endif()
include(CheckTypeSize)
CHECK_TYPE_SIZE(int _sizeof_int)
if (_sizeof_int EQUAL 4)
@@ -90,14 +91,19 @@ if(CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8)
set(MKL_ARCH_SUFFIX "ilp64")
endif()
else()
set(MKL_ARCH "ia32")
set(MKL_ARCH_LIST "ia32")
set(MKL_ARCH_SUFFIX "c")
endif()
if(MKL_VERSION_STR VERSION_GREATER "11.3.0" OR MKL_VERSION_STR VERSION_EQUAL "11.3.0")
set(mkl_lib_find_paths
${MKL_ROOT_DIR}/lib
${MKL_ROOT_DIR}/lib/${MKL_ARCH} ${MKL_ROOT_DIR}/../tbb/lib/${MKL_ARCH})
${MKL_ROOT_DIR}/lib)
foreach(MKL_ARCH ${MKL_ARCH_LIST})
list(APPEND mkl_lib_find_paths
${MKL_ROOT_DIR}/lib/${MKL_ARCH}
${MKL_ROOT_DIR}/../tbb/lib/${MKL_ARCH}
${MKL_ROOT_DIR}/${MKL_ARCH})
endforeach()
set(mkl_lib_list "mkl_intel_${MKL_ARCH_SUFFIX}")
@@ -121,7 +127,7 @@ endif()
set(MKL_LIBRARIES "")
foreach(lib ${mkl_lib_list})
find_library(${lib} ${lib} ${mkl_lib_find_paths})
find_library(${lib} NAMES ${lib} ${lib}_dll HINTS ${mkl_lib_find_paths})
mark_as_advanced(${lib})
if(NOT ${lib})
mkl_fail()
+2 -1
View File
@@ -46,6 +46,7 @@
SET(Open_BLAS_INCLUDE_SEARCH_PATHS
$ENV{OpenBLAS_HOME}
$ENV{OpenBLAS_HOME}/include
$ENV{OpenBLAS_HOME}/include/openblas
/opt/OpenBLAS/include
/usr/local/include/openblas
/usr/include/openblas
@@ -103,4 +104,4 @@ MARK_AS_ADVANCED(
OpenBLAS_INCLUDE_DIR
OpenBLAS_LIB
OpenBLAS
)
)
+1 -1
View File
@@ -88,7 +88,7 @@ FOREACH(SEARCH_PATH ${SEARCH_PATHS})
ocv_find_openexr("-${OPENEXR_VERSION}")
ocv_find_openexr("-${OPENEXR_VERSION}_s")
ocv_find_openexr("-${OPENEXR_VERSION}_d")
ocv_find_openexr("-${OPEXEXR_VERSION}_s_d")
ocv_find_openexr("-${OPENEXR_VERSION}_s_d")
ocv_find_openexr("")
ocv_find_openexr("_s")
ocv_find_openexr("_d")
+25 -10
View File
@@ -6,9 +6,15 @@ if(NOT WITH_PROTOBUF)
return()
endif()
ocv_option(BUILD_PROTOBUF "Force to build libprotobuf from sources" ON)
ocv_option(BUILD_PROTOBUF "Force to build libprotobuf runtime from sources" ON)
ocv_option(PROTOBUF_UPDATE_FILES "Force rebuilding .proto files (protoc should be available)" OFF)
# BUILD_PROTOBUF=OFF: Custom manual protobuf configuration (see find_package(Protobuf) for details):
# - Protobuf_INCLUDE_DIR
# - Protobuf_LIBRARY
# - Protobuf_PROTOC_EXECUTABLE
function(get_protobuf_version version include)
file(STRINGS "${include}/google/protobuf/stubs/common.h" ver REGEX "#define GOOGLE_PROTOBUF_VERSION [0-9]+")
string(REGEX MATCHALL "[0-9]+" ver ${ver})
@@ -19,7 +25,9 @@ function(get_protobuf_version version include)
endfunction()
if(BUILD_PROTOBUF)
ocv_assert(NOT PROTOBUF_UPDATE_FILES)
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/protobuf")
set(Protobuf_LIBRARIES "libprotobuf")
set(HAVE_PROTOBUF TRUE)
else()
unset(Protobuf_VERSION CACHE)
@@ -44,10 +52,7 @@ else()
if(Protobuf_FOUND)
if(TARGET protobuf::libprotobuf)
add_library(libprotobuf INTERFACE IMPORTED)
set_target_properties(libprotobuf PROPERTIES
INTERFACE_LINK_LIBRARIES protobuf::libprotobuf
)
set(Protobuf_LIBRARIES "protobuf::libprotobuf")
else()
add_library(libprotobuf UNKNOWN IMPORTED)
set_target_properties(libprotobuf PROPERTIES
@@ -56,21 +61,31 @@ else()
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${Protobuf_INCLUDE_DIR}"
)
get_protobuf_version(Protobuf_VERSION "${Protobuf_INCLUDE_DIR}")
set(Protobuf_LIBRARIES "libprotobuf")
endif()
set(HAVE_PROTOBUF TRUE)
endif()
endif()
if(HAVE_PROTOBUF AND PROTOBUF_UPDATE_FILES AND NOT COMMAND PROTOBUF_GENERATE_CPP)
find_package(Protobuf QUIET)
if(NOT COMMAND PROTOBUF_GENERATE_CPP)
message(FATAL_ERROR "PROTOBUF_GENERATE_CPP command is not available")
endif()
message(FATAL_ERROR "Can't configure protobuf dependency (BUILD_PROTOBUF=${BUILD_PROTOBUF} PROTOBUF_UPDATE_FILES=${PROTOBUF_UPDATE_FILES})")
endif()
if(HAVE_PROTOBUF)
list(APPEND CUSTOM_STATUS protobuf)
if(NOT BUILD_PROTOBUF)
if(TARGET "${Protobuf_LIBRARIES}")
get_target_property(__location "${Protobuf_LIBRARIES}" IMPORTED_LOCATION_RELEASE)
if(NOT __location)
get_target_property(__location "${Protobuf_LIBRARIES}" IMPORTED_LOCATION)
endif()
elseif(Protobuf_LIBRARY)
set(__location "${Protobuf_LIBRARY}")
else()
set(__location "${Protobuf_LIBRARIES}")
endif()
endif()
list(APPEND CUSTOM_STATUS_protobuf " Protobuf:"
BUILD_PROTOBUF THEN "build (${Protobuf_VERSION})"
ELSE "${Protobuf_LIBRARY} (${Protobuf_VERSION})")
ELSE "${__location} (${Protobuf_VERSION})")
endif()
+3 -4
View File
@@ -5,10 +5,9 @@
# VA_INTEL_IOCL_ROOT - root of Intel OCL installation
if(UNIX AND NOT ANDROID)
if($ENV{VA_INTEL_IOCL_ROOT})
set(VA_INTEL_IOCL_ROOT $ENV{VA_INTEL_IOCL_ROOT})
else()
set(VA_INTEL_IOCL_ROOT "/opt/intel/opencl")
ocv_check_environment_variables(VA_INTEL_IOCL_ROOT)
if(NOT DEFINED VA_INTEL_IOCL_ROOT)
set(VA_INTEL_IOCL_ROOT "/opt/intel/opencl")
endif()
find_path(
+25 -4
View File
@@ -1083,6 +1083,17 @@ macro(ocv_check_dependencies)
endforeach()
endmacro()
################################################################################
# OpenCV tests
################################################################################
if(DEFINED OPENCV_BUILD_TEST_MODULES_LIST)
string(REPLACE "," ";" OPENCV_BUILD_TEST_MODULES_LIST "${OPENCV_BUILD_TEST_MODULES_LIST}") # support comma-separated list (,) too
endif()
if(DEFINED OPENCV_BUILD_PERF_TEST_MODULES_LIST)
string(REPLACE "," ";" OPENCV_BUILD_PERF_TEST_MODULES_LIST "${OPENCV_BUILD_PERF_TEST_MODULES_LIST}") # support comma-separated list (,) too
endif()
# auxiliary macro to parse arguments of ocv_add_accuracy_tests and ocv_add_perf_tests commands
macro(__ocv_parse_test_sources tests_type)
set(OPENCV_${tests_type}_${the_module}_SOURCES "")
@@ -1123,7 +1134,12 @@ function(ocv_add_perf_tests)
endif()
set(perf_path "${CMAKE_CURRENT_LIST_DIR}/perf")
if(BUILD_PERF_TESTS AND EXISTS "${perf_path}")
if(BUILD_PERF_TESTS AND EXISTS "${perf_path}"
AND (NOT DEFINED OPENCV_BUILD_PERF_TEST_MODULES_LIST
OR OPENCV_BUILD_PERF_TEST_MODULES_LIST STREQUAL "all"
OR ";${OPENCV_BUILD_PERF_TEST_MODULES_LIST};" MATCHES ";${name};"
)
)
__ocv_parse_test_sources(PERF ${ARGN})
# opencv_imgcodecs is required for imread/imwrite
@@ -1199,7 +1215,12 @@ function(ocv_add_accuracy_tests)
ocv_debug_message("ocv_add_accuracy_tests(" ${ARGN} ")")
set(test_path "${CMAKE_CURRENT_LIST_DIR}/test")
if(BUILD_TESTS AND EXISTS "${test_path}")
if(BUILD_TESTS AND EXISTS "${test_path}"
AND (NOT DEFINED OPENCV_BUILD_TEST_MODULES_LIST
OR OPENCV_BUILD_TEST_MODULES_LIST STREQUAL "all"
OR ";${OPENCV_BUILD_TEST_MODULES_LIST};" MATCHES ";${name};"
)
)
__ocv_parse_test_sources(TEST ${ARGN})
# opencv_imgcodecs is required for imread/imwrite
@@ -1316,8 +1337,8 @@ function(ocv_add_samples)
endif()
add_dependencies(${parent_target} ${the_target})
if(WIN32)
install(TARGETS ${the_target} RUNTIME DESTINATION "samples/${module_id}" COMPONENT samples)
if(INSTALL_BIN_EXAMPLES)
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${module_id}" COMPONENT samples)
endif()
endforeach()
endif()
Executable → Regular
View File
+23 -20
View File
@@ -1,25 +1,28 @@
# -----------------------------------------------
# File that provides "make uninstall" target
# We use the file 'install_manifest.txt'
#
# Details: https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#can-i-do-make-uninstall-with-cmake
# -----------------------------------------------
IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
STRING(REGEX REPLACE "\n" ";" files "${files}")
FOREACH(file ${files})
MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
IF(EXISTS "$ENV{DESTDIR}${file}")
EXEC_PROGRAM(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
IF(NOT "${rm_retval}" STREQUAL 0)
MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
ENDIF(NOT "${rm_retval}" STREQUAL 0)
ELSE(EXISTS "$ENV{DESTDIR}${file}")
MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
ENDIF(EXISTS "$ENV{DESTDIR}${file}")
ENDFOREACH(file)
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_BINARY_DIR@/install_manifest.txt\"")
endif()
file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif()
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif()
endforeach()
+2 -3
View File
@@ -13,9 +13,6 @@
/* Compile for 'real' NVIDIA GPU architectures */
#define CUDA_ARCH_BIN "${OPENCV_CUDA_ARCH_BIN}"
/* Create PTX or BIN for 1.0 compute capability */
#cmakedefine CUDA_ARCH_BIN_OR_PTX_10
/* NVIDIA GPU features are used */
#define CUDA_ARCH_FEATURES "${OPENCV_CUDA_ARCH_FEATURES}"
@@ -127,6 +124,8 @@
/* NVIDIA Video Decoding API*/
#cmakedefine HAVE_NVCUVID
#cmakedefine HAVE_NVCUVID_HEADER
#cmakedefine HAVE_DYNLINK_NVCUVID_HEADER
/* NVIDIA Video Encoding API*/
#cmakedefine HAVE_NVCUVENC
View File
View File
View File
View File
View File
+1 -1
View File
@@ -241,7 +241,7 @@ PREDEFINED = __cplusplus=1 \
CV_WRAP= \
CV_WRAP_AS(x)= \
CV_CDECL= \
CV_Func = \
CV_Func= \
CV_DO_PRAGMA(x)= \
CV_SUPPRESS_DEPRECATED_START= \
CV_SUPPRESS_DEPRECATED_END= \
+1 -20
View File
@@ -1,23 +1,4 @@
Frequently Asked Questions {#faq}
==========================
- **What is InputArray?**
It can be seen that almost all OpenCV functions receive InputArray type.
What is it, and how can I understand the actual input types of parameters?
This is the proxy class for passing read-only input arrays into OpenCV functions.
Inside a function you should use cv::_InputArray::getMat() method to construct
a matrix header for the array (without copying data). cv::_InputArray::kind() can be used to distinguish Mat from vector<> etc.
but normally it is not needed.
for more information see cv::_InputArray
- **Which is more efficient, use contourArea() or count number of ROI non-zero pixels?**
In a case where you only want relative areas, which one is faster to compute:
calculate a contour area or count the number of ROI non-zero pixels?
cv::contourArea() uses Green formula (http://en.wikipedia.org/wiki/Green's_theorem) to compute the area, therefore its complexity is O(contour_number_of_vertices). Counting non-zero pixels in the ROI is O(roi_width*roi_height) algorithm, i.e. much slower. Note, however, that because of finite, and quite low, resolution of the raster grid, the two algorithms will give noticeably different results. For large and square-like contours the error will be minimal. For small and/or oblong contours the error can be quite large.
Compatibility page. FAQ migrated to the project [wiki](https://github.com/opencv/opencv/wiki/FAQ).
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

@@ -146,7 +146,7 @@ npm install canvas jsdom
@code{.js}
const { Canvas, createCanvas, Image, ImageData, loadImage } = require('canvas');
const { JSDOM } = require('jsdom');
const { writeFileSync } = require('fs');
const { writeFileSync, existsSync, mkdirSync } = require("fs");
// This is our program. This time we use JavaScript async / await and promises to handle asynchronicity.
(async () => {
@@ -1,6 +1,8 @@
Build OpenCV.js {#tutorial_js_setup}
===============================
@note
You don't have to build your own copy if you simply want to start using it. Refer the Using Opencv.js tutorial for steps on getting a prebuilt copy from our releases or online documentation.
Installing Emscripten
-----------------------------
@@ -4,7 +4,7 @@ Using OpenCV.js {#tutorial_js_usage}
Steps
-----
In this tutorial, you will learn how to include and start to use `opencv.js` inside a web page.
In this tutorial, you will learn how to include and start to use `opencv.js` inside a web page. You can get a copy of `opencv.js` from `opencv-{VERSION_NUMBER}-docs.zip` in each [release](https://github.com/opencv/opencv/releases), or simply download the prebuilt script from the online documentations at "https://docs.opencv.org/{VERISON_NUMBER}/opencv.js" (For example, [https://docs.opencv.org/3.4.0/opencv.js](https://docs.opencv.org/3.4.0/opencv.js). Use `master` if you want the latest build). You can also build your own copy by following the tutorial on Build Opencv.js.
### Create a web page
@@ -44,7 +44,7 @@ To run this web page, copy the content above and save to a local index.html file
Set the URL of `opencv.js` to `src` attribute of \<script\> tag.
@note For this tutorial, we host `opencv.js` at same folder as index.html.
@note For this tutorial, we host `opencv.js` at same folder as index.html. You can also choose to use the URL of the prebuilt `opencv.js` in our online documentation.
Example for synchronous loading:
@code{.js}
+3
View File
@@ -9,6 +9,9 @@ MathJax.Hub.Config(
forkfour: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ #7 & \\mbox{#8}\\\\ \\end{array} \\right.", 8],
vecthree: ["\\begin{bmatrix} #1\\\\ #2\\\\ #3 \\end{bmatrix}", 3],
vecthreethree: ["\\begin{bmatrix} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{bmatrix}", 9],
cameramatrix: ["#1 = \\begin{bmatrix} f_x & 0 & c_x\\\\ 0 & f_y & c_y\\\\ 0 & 0 & 1 \\end{bmatrix}", 1],
distcoeffs: ["(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \\tau_x, \\tau_y]]]]) \\text{ of 4, 5, 8, 12 or 14 elements}"],
distcoeffsfisheye: ["(k_1, k_2, k_3, k_4)"],
hdotsfor: ["\\dots", 1],
mathbbm: ["\\mathbb{#1}", 1],
bordermatrix: ["\\matrix{#1}", 1]
+18 -1
View File
@@ -28,7 +28,7 @@
#3 & \mbox{#4}\\
#5 & \mbox{#6}\\
\end{array} \right.}
\newcommand{\forkthree}[8]{
\newcommand{\forkfour}[8]{
\left\{
\begin{array}{l l}
#1 & \mbox{#2}\\
@@ -51,3 +51,20 @@
#7 & #8 & #9
\end{bmatrix}
}
\newcommand{\cameramatrix}[1]{
#1 =
\begin{bmatrix}
f_x & 0 & c_x\\
0 & f_y & c_y\\
0 & 0 & 1
\end{bmatrix}
}
\newcommand{\distcoeffs}[]{
(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]]) \text{ of 4, 5, 8, 12 or 14 elements}
}
\newcommand{\distcoeffsfisheye}[]{
(k_1, k_2, k_3, k_4)
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

+9
View File
@@ -0,0 +1,9 @@
OpenCV logo has been originally designed and contributed to OpenCV by Adi Shavit in 2006. The graphical part consists of three stylized letters O, C, V, colored in the primary R, G, B color components, used by humans and computers to perceive the world. It is shaped in a way to mimic the famous [Kanizsa's triangle](https://en.wikipedia.org/wiki/Illusory_contours) to emphasize that the prior knowledge and internal processing are at least as important as the actually acquired "raw" data.
The restyled version of the logo has been designed and contributed by [xperience.ai](https://xperience.ai/) in July 2020 for the [20th anniversary](https://opencv.org/anniversary/) of OpenCV.
The logo uses [Exo 2](https://fonts.google.com/specimen/Exo+2#about) font by Natanael Gama distributed under OFL license.
Higher-resolution version of the logo, as well as SVG version of it, can be obtained at OpenCV [Media Kit](https://opencv.org/resources/media-kit/).
![](./opencv-logo2.png)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 42 KiB

+33 -2
View File
@@ -346,7 +346,8 @@
year = {2003},
pages = {363--370},
publisher = {Springer},
url = {https://arxiv.org/pdf/1808.01752}
url = {https://doi.org/10.1007/3-540-45103-X_50},
doi = {10.1007/3-540-45103-X_50}
}
@inproceedings{Farsiu03,
author = {Farsiu, Sina and Robinson, Dirk and Elad, Michael and Milanfar, Peyman},
@@ -583,6 +584,16 @@
pages = {1033--1040},
publisher = {IEEE}
}
@article{YM11,
author = {Yu, Guoshen and Morel, Jean-Michel},
title = {ASIFT: An Algorithm for Fully Affine Invariant Comparison},
year = {2011},
pages = {11--38},
journal = {Image Processing On Line},
volume = {1},
doi = {10.5201/ipol.2011.my-asift},
url = {http://www.ipol.im/pub/algo/my_affine_sift/}
}
@inproceedings{LCS11,
author = {Leutenegger, Stefan and Chli, Margarita and Siegwart, Roland Yves},
title = {BRISK: Binary robust invariant scalable keypoints},
@@ -620,7 +631,7 @@
volume = {1},
publisher = {IEEE}
}
@article{Lowe:2004:DIF:993451.996342,
@article{Lowe04,
author = {Lowe, David G.},
title = {Distinctive Image Features from Scale-Invariant Keypoints},
journal = {Int. J. Comput. Vision},
@@ -1214,3 +1225,23 @@
year = {1996},
publisher = {Elsevier}
}
@Article{Wu2009,
author={Wu, Kesheng
and Otoo, Ekow
and Suzuki, Kenji},
title={Optimizing two-pass connected-component labeling algorithms},
journal={Pattern Analysis and Applications},
year={2009},
month={Jun},
day={01},
volume={12},
number={2},
pages={117-135},
}
@inproceedings{forstner1987fast,
title={A fast operator for detection and precise location of distincs points, corners and center of circular features},
author={FORSTNER, W},
booktitle={Proc. of the Intercommission Conference on Fast Processing of Photogrammetric Data, Interlaken, Switzerland, 1987},
pages={281--305},
year={1987}
}
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

+93 -88
View File
@@ -16,110 +16,115 @@ python gen_pattern.py -o out.svg -r 11 -c 8 -T circles -s 20.0 -R 5.0 -u mm -w 2
-H, --help - show help
"""
import argparse
from svgfig import *
import sys
import getopt
class PatternMaker:
def __init__(self, cols,rows,output,units,square_size,radius_rate,page_width,page_height):
self.cols = cols
self.rows = rows
self.output = output
self.units = units
self.square_size = square_size
self.radius_rate = radius_rate
self.width = page_width
self.height = page_height
self.g = SVG("g") # the svg group container
def __init__(self, cols, rows, output, units, square_size, radius_rate, page_width, page_height):
self.cols = cols
self.rows = rows
self.output = output
self.units = units
self.square_size = square_size
self.radius_rate = radius_rate
self.width = page_width
self.height = page_height
self.g = SVG("g") # the svg group container
def makeCirclesPattern(self):
spacing = self.square_size
r = spacing / self.radius_rate
for x in range(1,self.cols+1):
for y in range(1,self.rows+1):
dot = SVG("circle", cx=x * spacing, cy=y * spacing, r=r, fill="black", stroke="none")
self.g.append(dot)
def make_circles_pattern(self):
spacing = self.square_size
r = spacing / self.radius_rate
pattern_width = ((self.cols - 1.0) * spacing) + (2.0 * r)
pattern_height = ((self.rows - 1.0) * spacing) + (2.0 * r)
x_spacing = (self.width - pattern_width) / 2.0
y_spacing = (self.height - pattern_height) / 2.0
for x in range(0, self.cols):
for y in range(0, self.rows):
dot = SVG("circle", cx=(x * spacing) + x_spacing + r,
cy=(y * spacing) + y_spacing + r, r=r, fill="black", stroke="none")
self.g.append(dot)
def makeACirclesPattern(self):
spacing = self.square_size
r = spacing / self.radius_rate
for i in range(0,self.rows):
for j in range(0,self.cols):
dot = SVG("circle", cx= ((j*2 + i%2)*spacing) + spacing, cy=self.height - (i * spacing + spacing), r=r, fill="black", stroke="none")
self.g.append(dot)
def make_acircles_pattern(self):
spacing = self.square_size
r = spacing / self.radius_rate
pattern_width = ((self.cols-1.0) * 2 * spacing) + spacing + (2.0 * r)
pattern_height = ((self.rows-1.0) * spacing) + (2.0 * r)
x_spacing = (self.width - pattern_width) / 2.0
y_spacing = (self.height - pattern_height) / 2.0
for x in range(0, self.cols):
for y in range(0, self.rows):
dot = SVG("circle", cx=(2 * x * spacing) + (y % 2)*spacing + x_spacing + r,
cy=(y * spacing) + y_spacing + r, r=r, fill="black", stroke="none")
self.g.append(dot)
def makeCheckerboardPattern(self):
spacing = self.square_size
xspacing = (self.width - self.cols * self.square_size) / 2.0
yspacing = (self.height - self.rows * self.square_size) / 2.0
for x in range(0,self.cols):
for y in range(0,self.rows):
if x%2 == y%2:
square = SVG("rect", x=x * spacing + xspacing, y=y * spacing + yspacing, width=spacing, height=spacing, fill="black", stroke="none")
self.g.append(square)
def make_checkerboard_pattern(self):
spacing = self.square_size
xspacing = (self.width - self.cols * self.square_size) / 2.0
yspacing = (self.height - self.rows * self.square_size) / 2.0
for x in range(0, self.cols):
for y in range(0, self.rows):
if x % 2 == y % 2:
square = SVG("rect", x=x * spacing + xspacing, y=y * spacing + yspacing, width=spacing,
height=spacing, fill="black", stroke="none")
self.g.append(square)
def save(self):
c = canvas(self.g,width="%d%s"%(self.width,self.units),height="%d%s"%(self.height,self.units),viewBox="0 0 %d %d"%(self.width,self.height))
c.save(self.output)
def save(self):
c = canvas(self.g, width="%d%s" % (self.width, self.units), height="%d%s" % (self.height, self.units),
viewBox="0 0 %d %d" % (self.width, self.height))
c.save(self.output)
def main():
# parse command line options, TODO use argparse for better doc
try:
opts, args = getopt.getopt(sys.argv[1:], "Ho:c:r:T:u:s:R:w:h:a:", ["help","output=","columns=","rows=",
"type=","units=","square_size=","radius_rate=",
"page_width=","page_height=", "page_size="])
except getopt.error as msg:
print(msg)
print("for help use --help")
sys.exit(2)
output = "out.svg"
columns = 8
rows = 11
p_type = "circles"
units = "mm"
square_size = 20.0
radius_rate = 5.0
page_size = "A4"
# parse command line options
parser = argparse.ArgumentParser(description="generate camera-calibration pattern", add_help=False)
parser.add_argument("-H", "--help", help="show help", action="store_true", dest="show_help")
parser.add_argument("-o", "--output", help="output file", default="out.svg", action="store", dest="output")
parser.add_argument("-c", "--columns", help="pattern columns", default="8", action="store", dest="columns",
type=int)
parser.add_argument("-r", "--rows", help="pattern rows", default="11", action="store", dest="rows", type=int)
parser.add_argument("-T", "--type", help="type of pattern", default="circles", action="store", dest="p_type",
choices=["circles", "acircles", "checkerboard"])
parser.add_argument("-u", "--units", help="length unit", default="mm", action="store", dest="units",
choices=["mm", "inches", "px", "m"])
parser.add_argument("-s", "--square_size", help="size of squares in pattern", default="20.0", action="store",
dest="square_size", type=float)
parser.add_argument("-R", "--radius_rate", help="circles_radius = square_size/radius_rate", default="5.0",
action="store", dest="radius_rate", type=float)
parser.add_argument("-w", "--page_width", help="page width in units", default="216", action="store",
dest="page_width", type=float)
parser.add_argument("-h", "--page_height", help="page height in units", default="279", action="store",
dest="page_width", type=float)
parser.add_argument("-a", "--page_size", help="page size, supersedes -h -w arguments", default="A4", action="store",
dest="page_size", choices=["A0", "A1", "A2", "A3", "A4", "A5"])
args = parser.parse_args()
show_help = args.show_help
if show_help:
parser.print_help()
return
output = args.output
columns = args.columns
rows = args.rows
p_type = args.p_type
units = args.units
square_size = args.square_size
radius_rate = args.radius_rate
page_size = args.page_size
# page size dict (ISO standard, mm) for easy lookup. format - size: [width, height]
page_sizes = {"A0": [840, 1188], "A1": [594, 840], "A2": [420, 594], "A3": [297, 420], "A4": [210, 297], "A5": [148, 210]}
page_sizes = {"A0": [840, 1188], "A1": [594, 840], "A2": [420, 594], "A3": [297, 420], "A4": [210, 297],
"A5": [148, 210]}
page_width = page_sizes[page_size.upper()][0]
page_height = page_sizes[page_size.upper()][1]
# process options
for o, a in opts:
if o in ("-H", "--help"):
print(__doc__)
sys.exit(0)
elif o in ("-r", "--rows"):
rows = int(a)
elif o in ("-c", "--columns"):
columns = int(a)
elif o in ("-o", "--output"):
output = a
elif o in ("-T", "--type"):
p_type = a
elif o in ("-u", "--units"):
units = a
elif o in ("-s", "--square_size"):
square_size = float(a)
elif o in ("-R", "--radius_rate"):
radius_rate = float(a)
elif o in ("-w", "--page_width"):
page_width = float(a)
elif o in ("-h", "--page_height"):
page_height = float(a)
elif o in ("-a", "--page_size"):
units = "mm"
page_size = a.upper()
page_width = page_sizes[page_size][0]
page_height = page_sizes[page_size][1]
pm = PatternMaker(columns,rows,output,units,square_size,radius_rate,page_width,page_height)
#dict for easy lookup of pattern type
mp = {"circles":pm.makeCirclesPattern,"acircles":pm.makeACirclesPattern,"checkerboard":pm.makeCheckerboardPattern}
pm = PatternMaker(columns, rows, output, units, square_size, radius_rate, page_width, page_height)
# dict for easy lookup of pattern type
mp = {"circles": pm.make_circles_pattern, "acircles": pm.make_acircles_pattern,
"checkerboard": pm.make_checkerboard_pattern}
mp[p_type]()
#this should save pattern to output
# this should save pattern to output
pm.save()
if __name__ == "__main__":
main()
@@ -44,7 +44,7 @@ img1 = cv.imread('box.png',0) # queryImage
img2 = cv.imread('box_in_scene.png',0) # trainImage
# Initiate SIFT detector
sift = cv.xfeatures2d.SIFT_create()
sift = cv.SIFT_create()
# find the keypoints and descriptors with SIFT
kp1, des1 = sift.detectAndCompute(img1,None)
@@ -110,7 +110,7 @@ img1 = cv.imread('box.png',cv.IMREAD_GRAYSCALE) # queryImage
img2 = cv.imread('box_in_scene.png',cv.IMREAD_GRAYSCALE) # trainImage
# Initiate SIFT detector
sift = cv.xfeatures2d.SIFT_create()
sift = cv.SIFT_create()
# find the keypoints and descriptors with SIFT
kp1, des1 = sift.detectAndCompute(img1,None)
@@ -174,7 +174,7 @@ img1 = cv.imread('box.png',cv.IMREAD_GRAYSCALE) # queryImage
img2 = cv.imread('box_in_scene.png',cv.IMREAD_GRAYSCALE) # trainImage
# Initiate SIFT detector
sift = cv.xfeatures2d.SIFT_create()
sift = cv.SIFT_create()
# find the keypoints and descriptors with SIFT
kp1, des1 = sift.detectAndCompute(img1,None)
@@ -119,7 +119,7 @@ import cv2 as cv
img = cv.imread('home.jpg')
gray= cv.cvtColor(img,cv.COLOR_BGR2GRAY)
sift = cv.xfeatures2d.SIFT_create()
sift = cv.SIFT_create()
kp = sift.detect(gray,None)
img=cv.drawKeypoints(gray,kp,img)
@@ -151,7 +151,7 @@ Now to calculate the descriptor, OpenCV provides two methods.
We will see the second method:
@code{.py}
sift = cv.xfeatures2d.SIFT_create()
sift = cv.SIFT_create()
kp, des = sift.detectAndCompute(gray,None)
@endcode
Here kp will be a list of keypoints and des is a numpy array of shape
Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

@@ -1,153 +1,4 @@
Getting Started with Images {#tutorial_py_image_display}
===========================
Goals
-----
- Here, you will learn how to read an image, how to display it, and how to save it back
- You will learn these functions : **cv.imread()**, **cv.imshow()** , **cv.imwrite()**
- Optionally, you will learn how to display images with Matplotlib
Using OpenCV
------------
### Read an image
Use the function **cv.imread()** to read an image. The image should be in the working directory or
a full path of image should be given.
Second argument is a flag which specifies the way image should be read.
- cv.IMREAD_COLOR : Loads a color image. Any transparency of image will be neglected. It is the
default flag.
- cv.IMREAD_GRAYSCALE : Loads image in grayscale mode
- cv.IMREAD_UNCHANGED : Loads image as such including alpha channel
@note Instead of these three flags, you can simply pass integers 1, 0 or -1 respectively.
See the code below:
@code{.py}
import numpy as np
import cv2 as cv
# Load a color image in grayscale
img = cv.imread('messi5.jpg',0)
@endcode
**warning**
Even if the image path is wrong, it won't throw any error, but `print img` will give you `None`
### Display an image
Use the function **cv.imshow()** to display an image in a window. The window automatically fits to
the image size.
First argument is a window name which is a string. Second argument is our image. You can create as
many windows as you wish, but with different window names.
@code{.py}
cv.imshow('image',img)
cv.waitKey(0)
cv.destroyAllWindows()
@endcode
A screenshot of the window will look like this (in Fedora-Gnome machine):
![image](images/opencv_screenshot.jpg)
**cv.waitKey()** is a keyboard binding function. Its argument is the time in milliseconds. The
function waits for specified milliseconds for any keyboard event. If you press any key in that time,
the program continues. If **0** is passed, it waits indefinitely for a key stroke. It can also be
set to detect specific key strokes like, if key a is pressed etc which we will discuss below.
@note Besides binding keyboard events this function also processes many other GUI events, so you
MUST use it to actually display the image.
**cv.destroyAllWindows()** simply destroys all the windows we created. If you want to destroy any
specific window, use the function **cv.destroyWindow()** where you pass the exact window name as
the argument.
@note There is a special case where you can create an empty window and load an image to it later. In
that case, you can specify whether the window is resizable or not. It is done with the function
**cv.namedWindow()**. By default, the flag is cv.WINDOW_AUTOSIZE. But if you specify the flag to be
cv.WINDOW_NORMAL, you can resize window. It will be helpful when an image is too large in dimension
and when adding track bars to windows.
See the code below:
@code{.py}
cv.namedWindow('image', cv.WINDOW_NORMAL)
cv.imshow('image',img)
cv.waitKey(0)
cv.destroyAllWindows()
@endcode
### Write an image
Use the function **cv.imwrite()** to save an image.
First argument is the file name, second argument is the image you want to save.
@code{.py}
cv.imwrite('messigray.png',img)
@endcode
This will save the image in PNG format in the working directory.
### Sum it up
Below program loads an image in grayscale, displays it, saves the image if you press 's' and exit, or
simply exits without saving if you press ESC key.
@code{.py}
import numpy as np
import cv2 as cv
img = cv.imread('messi5.jpg',0)
cv.imshow('image',img)
k = cv.waitKey(0)
if k == 27: # wait for ESC key to exit
cv.destroyAllWindows()
elif k == ord('s'): # wait for 's' key to save and exit
cv.imwrite('messigray.png',img)
cv.destroyAllWindows()
@endcode
**warning**
If you are using a 64-bit machine, you will have to modify `k = cv.waitKey(0)` line as follows :
`k = cv.waitKey(0) & 0xFF`
Using Matplotlib
----------------
Matplotlib is a plotting library for Python which gives you wide variety of plotting methods. You
will see them in coming articles. Here, you will learn how to display image with Matplotlib. You can
zoom images, save them, etc, using Matplotlib.
@code{.py}
import numpy as np
import cv2 as cv
from matplotlib import pyplot as plt
img = cv.imread('messi5.jpg',0)
plt.imshow(img, cmap = 'gray', interpolation = 'bicubic')
plt.xticks([]), plt.yticks([]) # to hide tick values on X and Y axis
plt.show()
@endcode
A screen-shot of the window will look like this :
![image](images/matplotlib_screenshot.jpg)
@note Plenty of plotting options are available in Matplotlib. Please refer to Matplotlib docs for more
details. Some, we will see on the way.
__warning__
Color image loaded by OpenCV is in BGR mode. But Matplotlib displays in RGB mode. So color images
will not be displayed correctly in Matplotlib if image is read with OpenCV. Please see the exercises
for more details.
Additional Resources
--------------------
-# [Matplotlib Plotting Styles and Features](http://matplotlib.org/api/pyplot_api.html)
Exercises
---------
-# There is some problem when you try to load color image in OpenCV and display it in Matplotlib.
Read [this discussion](http://stackoverflow.com/a/15074748/1134940) and understand it.
Tutorial content has been moved: @ref tutorial_display_image
@@ -1,7 +1,7 @@
Gui Features in OpenCV {#tutorial_py_table_of_contents_gui}
======================
- @subpage tutorial_py_image_display
- @ref tutorial_display_image
Learn to load an
image, display it, and save it back
@@ -78,7 +78,7 @@ pixelpoints = np.transpose(np.nonzero(mask))
Here, two methods, one using Numpy functions, next one using OpenCV function (last commented line)
are given to do the same. Results are also same, but with a slight difference. Numpy gives
coordinates in **(row, column)** format, while OpenCV gives coordinates in **(x,y)** format. So
basically the answers will be interchanged. Note that, **row = x** and **column = y**.
basically the answers will be interchanged. Note that, **row = y** and **column = x**.
7. Maximum Value, Minimum Value and their locations
---------------------------------------------------
@@ -80,7 +80,7 @@ Probabilistic Hough Transform
In the hough transform, you can see that even for a line with two arguments, it takes a lot of
computation. Probabilistic Hough Transform is an optimization of the Hough Transform we saw. It doesn't
take all the points into consideration. Instead, it takes only a random subset of points which is
sufficient for line detection. Just we have to decrease the threshold. See image below which compares
sufficient for line detection. We just have to decrease the threshold. See image below which compares
Hough Transform and Probabilistic Hough Transform in Hough space. (Image Courtesy :
[Franck Bettinger's home page](http://phdfb1.free.fr/robot/mscthesis/node14.html) )
@@ -4,20 +4,20 @@ OCR of Hand-written Data using kNN {#tutorial_py_knn_opencv}
Goal
----
In this chapter
- We will use our knowledge on kNN to build a basic OCR application.
- We will try with Digits and Alphabets data available that comes with OpenCV.
In this chapter:
- We will use our knowledge on kNN to build a basic OCR (Optical Character Recognition) application.
- We will try our application on Digits and Alphabets data that comes with OpenCV.
OCR of Hand-written Digits
--------------------------
Our goal is to build an application which can read the handwritten digits. For this we need some
train_data and test_data. OpenCV comes with an image digits.png (in the folder
Our goal is to build an application which can read handwritten digits. For this we need some
training data and some test data. OpenCV comes with an image digits.png (in the folder
opencv/samples/data/) which has 5000 handwritten digits (500 for each digit). Each digit is
a 20x20 image. So our first step is to split this image into 5000 different digits. For each digit,
we flatten it into a single row with 400 pixels. That is our feature set, ie intensity values of all
pixels. It is the simplest feature set we can create. We use first 250 samples of each digit as
train_data, and next 250 samples as test_data. So let's prepare them first.
a 20x20 image. So our first step is to split this image into 5000 different digit images. Then for each digit (20x20 image),
we flatten it into a single row with 400 pixels. That is our feature set, i.e. intensity values of all
pixels. It is the simplest feature set we can create. We use the first 250 samples of each digit as
training data, and the other 250 samples as test data. So let's prepare them first.
@code{.py}
import numpy as np
import cv2 as cv
@@ -28,10 +28,10 @@ gray = cv.cvtColor(img,cv.COLOR_BGR2GRAY)
# Now we split the image to 5000 cells, each 20x20 size
cells = [np.hsplit(row,100) for row in np.vsplit(gray,50)]
# Make it into a Numpy array. It size will be (50,100,20,20)
# Make it into a Numpy array: its size will be (50,100,20,20)
x = np.array(cells)
# Now we prepare train_data and test_data.
# Now we prepare the training data and test data
train = x[:,:50].reshape(-1,400).astype(np.float32) # Size = (2500,400)
test = x[:,50:100].reshape(-1,400).astype(np.float32) # Size = (2500,400)
@@ -40,7 +40,7 @@ k = np.arange(10)
train_labels = np.repeat(k,250)[:,np.newaxis]
test_labels = train_labels.copy()
# Initiate kNN, train the data, then test it with test data for k=1
# Initiate kNN, train it on the training data, then test it with the test data with k=1
knn = cv.ml.KNearest_create()
knn.train(train, cv.ml.ROW_SAMPLE, train_labels)
ret,result,neighbours,dist = knn.findNearest(test,k=5)
@@ -52,13 +52,15 @@ correct = np.count_nonzero(matches)
accuracy = correct*100.0/result.size
print( accuracy )
@endcode
So our basic OCR app is ready. This particular example gave me an accuracy of 91%. One option
improve accuracy is to add more data for training, especially the wrong ones. So instead of finding
this training data every time I start application, I better save it, so that next time, I directly
read this data from a file and start classification. You can do it with the help of some Numpy
functions like np.savetxt, np.savez, np.load etc. Please check their docs for more details.
So our basic OCR app is ready. This particular example gave me an accuracy of 91%. One option to
improve accuracy is to add more data for training, especially for the digits where we had more errors.
Instead of finding
this training data every time I start the application, I better save it, so that the next time, I can directly
read this data from a file and start classification. This can be done with the help of some Numpy
functions like np.savetxt, np.savez, np.load, etc. Please check the NumPy docs for more details.
@code{.py}
# save the data
# Save the data
np.savez('knn_data.npz',train=train, train_labels=train_labels)
# Now load the data
@@ -71,36 +73,36 @@ In my system, it takes around 4.4 MB of memory. Since we are using intensity val
features, it would be better to convert the data to np.uint8 first and then save it. It takes only
1.1 MB in this case. Then while loading, you can convert back into float32.
OCR of English Alphabets
OCR of the English Alphabet
------------------------
Next we will do the same for English alphabets, but there is a slight change in data and feature
Next we will do the same for the English alphabet, but there is a slight change in data and feature
set. Here, instead of images, OpenCV comes with a data file, letter-recognition.data in
opencv/samples/cpp/ folder. If you open it, you will see 20000 lines which may, on first sight, look
like garbage. Actually, in each row, first column is an alphabet which is our label. Next 16 numbers
following it are its different features. These features are obtained from [UCI Machine Learning
like garbage. Actually, in each row, the first column is a letter which is our label. The next 16 numbers
following it are the different features. These features are obtained from the [UCI Machine Learning
Repository](http://archive.ics.uci.edu/ml/). You can find the details of these features in [this
page](http://archive.ics.uci.edu/ml/datasets/Letter+Recognition).
There are 20000 samples available, so we take first 10000 data as training samples and remaining
10000 as test samples. We should change the alphabets to ascii characters because we can't work with
alphabets directly.
There are 20000 samples available, so we take the first 10000 as training samples and the remaining
10000 as test samples. We should change the letters to ascii characters because we can't work with
letters directly.
@code{.py}
import cv2 as cv
import numpy as np
# Load the data, converters convert the letter to a number
# Load the data and convert the letters to numbers
data= np.loadtxt('letter-recognition.data', dtype= 'float32', delimiter = ',',
converters= {0: lambda ch: ord(ch)-ord('A')})
# split the data to two, 10000 each for train and test
# Split the dataset in two, with 10000 samples each for training and test sets
train, test = np.vsplit(data,2)
# split trainData and testData to features and responses
# Split trainData and testData into features and responses
responses, trainData = np.hsplit(train,[1])
labels, testData = np.hsplit(test,[1])
# Initiate the kNN, classify, measure accuracy.
# Initiate the kNN, classify, measure accuracy
knn = cv.ml.KNearest_create()
knn.train(trainData, cv.ml.ROW_SAMPLE, responses)
ret, result, neighbours, dist = knn.findNearest(testData, k=5)
@@ -110,10 +112,12 @@ accuracy = correct*100.0/10000
print( accuracy )
@endcode
It gives me an accuracy of 93.22%. Again, if you want to increase accuracy, you can iteratively add
error data in each level.
more data.
Additional Resources
--------------------
1. [Wikipedia article on Optical character recognition](https://en.wikipedia.org/wiki/Optical_character_recognition)
Exercises
---------
1. Here we used k=5. What happens if you try other values of k? Can you find a value that maximizes accuracy (minimizes the number of errors)?
@@ -4,61 +4,55 @@ Understanding k-Nearest Neighbour {#tutorial_py_knn_understanding}
Goal
----
In this chapter, we will understand the concepts of k-Nearest Neighbour (kNN) algorithm.
In this chapter, we will understand the concepts of the k-Nearest Neighbour (kNN) algorithm.
Theory
------
kNN is one of the simplest of classification algorithms available for supervised learning. The idea
is to search for closest match of the test data in feature space. We will look into it with below
kNN is one of the simplest classification algorithms available for supervised learning. The idea
is to search for the closest match(es) of the test data in the feature space. We will look into it with the below
image.
![image](images/knn_theory.png)
In the image, there are two families, Blue Squares and Red Triangles. We call each family as
**Class**. Their houses are shown in their town map which we call feature space. *(You can consider
a feature space as a space where all datas are projected. For example, consider a 2D coordinate
space. Each data has two features, x and y coordinates. You can represent this data in your 2D
coordinate space, right? Now imagine if there are three features, you need 3D space. Now consider N
features, where you need N-dimensional space, right? This N-dimensional space is its feature space.
In our image, you can consider it as a 2D case with two features)*.
In the image, there are two families: Blue Squares and Red Triangles. We refer to each family as
a **Class**. Their houses are shown in their town map which we call the **Feature Space**. You can consider
a feature space as a space where all data are projected. For example, consider a 2D coordinate
space. Each datum has two features, a x coordinate and a y coordinate. You can represent this datum in your 2D
coordinate space, right? Now imagine that there are three features, you will need 3D space. Now consider N
features: you need N-dimensional space, right? This N-dimensional space is its feature space.
In our image, you can consider it as a 2D case with two features.
Now a new member comes into the town and creates a new home, which is shown as green circle. He
should be added to one of these Blue/Red families. We call that process, **Classification**. What we
do? Since we are dealing with kNN, let us apply this algorithm.
Now consider what happens if a new member comes into the town and creates a new home, which is shown as the green circle. He
should be added to one of these Blue or Red families (or *classes*). We call that process, **Classification**. How exactly should this new member be classified? Since we are dealing with kNN, let us apply the algorithm.
One method is to check who is his nearest neighbour. From the image, it is clear it is the Red
Triangle family. So he is also added into Red Triangle. This method is called simply **Nearest
Neighbour**, because classification depends only on the nearest neighbour.
One simple method is to check who is his nearest neighbour. From the image, it is clear that it is a member of the Red
Triangle family. So he is classified as a Red Triangle. This method is called simply **Nearest Neighbour** classification, because classification depends only on the *nearest neighbour*.
But there is a problem with that. Red Triangle may be the nearest. But what if there are lot of Blue
Squares near to him? Then Blue Squares have more strength in that locality than Red Triangle. So
just checking nearest one is not sufficient. Instead we check some k nearest families. Then whoever
is majority in them, the new guy belongs to that family. In our image, let's take k=3, ie 3 nearest
families. He has two Red and one Blue (there are two Blues equidistant, but since k=3, we take only
But there is a problem with this approach! Red Triangle may be the nearest neighbour, but what if there are also a lot of Blue
Squares nearby? Then Blue Squares have more strength in that locality than Red Triangles, so
just checking the nearest one is not sufficient. Instead we may want to check some **k** nearest families. Then whichever family is the majority amongst them, the new guy should belong to that family. In our image, let's take k=3, i.e. consider the 3 nearest
neighbours. The new member has two Red neighbours and one Blue neighbour (there are two Blues equidistant, but since k=3, we can take only
one of them), so again he should be added to Red family. But what if we take k=7? Then he has 5 Blue
families and 2 Red families. Great!! Now he should be added to Blue family. So it all changes with
value of k. More funny thing is, what if k = 4? He has 2 Red and 2 Blue neighbours. It is a tie !!!
So better take k as an odd number. So this method is called **k-Nearest Neighbour** since
classification depends on k nearest neighbours.
neighbours and 2 Red neighbours and should be added to the Blue family. The result will vary with the selected
value of k. Note that if k is not an odd number, we can get a tie, as would happen in the above case with k=4. We would see that our new member has 2 Red and 2 Blue neighbours as his four nearest neighbours and we would need to choose a method for breaking the tie to perform classification. So to reiterate, this method is called **k-Nearest Neighbour** since
classification depends on the *k nearest neighbours*.
Again, in kNN, it is true we are considering k neighbours, but we are giving equal importance to
all, right? Is it justice? For example, take the case of k=4. We told it is a tie. But see, the 2
Red families are more closer to him than the other 2 Blue families. So he is more eligible to be
added to Red. So how do we mathematically explain that? We give some weights to each family
depending on their distance to the new-comer. For those who are near to him get higher weights while
those are far away get lower weights. Then we add total weights of each family separately. Whoever
gets highest total weights, new-comer goes to that family. This is called **modified kNN**.
all, right? Is this justified? For example, take the tied case of k=4. As we can see, the 2
Red neighbours are actually closer to the new member than the other 2 Blue neighbours, so he is more eligible to be
added to the Red family. How do we mathematically explain that? We give some weights to each neighbour
depending on their distance to the new-comer: those who are nearer to him get higher weights, while
those that are farther away get lower weights. Then we add the total weights of each family separately and classify the new-comer as part of whichever family
received higher total weights. This is called **modified kNN** or **weighted kNN**.
So what are some important things you see here?
- You need to have information about all the houses in town, right? Because, we have to check
the distance from new-comer to all the existing houses to find the nearest neighbour. If there
are plenty of houses and families, it takes lots of memory, and more time for calculation
also.
- There is almost zero time for any kind of training or preparation.
- Because we have to check
the distance from the new-comer to all the existing houses to find the nearest neighbour(s), you need to have information about all of the houses in town, right? If there are plenty of houses and families, it takes a lot of memory, and also more time for calculation.
- There is almost zero time for any kind of "training" or preparation. Our "learning" involves only memorizing (storing) the data, before testing and classifying.
Now let's see it in OpenCV.
Now let's see this algorithm at work in OpenCV.
kNN in OpenCV
-------------
@@ -67,11 +61,11 @@ We will do a simple example here, with two families (classes), just like above.
chapter, we will do an even better example.
So here, we label the Red family as **Class-0** (so denoted by 0) and Blue family as **Class-1**
(denoted by 1). We create 25 families or 25 training data, and label them either Class-0 or Class-1.
We do all these with the help of Random Number Generator in Numpy.
(denoted by 1). We create 25 neighbours or 25 training data, and label each of them as either part of Class-0 or Class-1.
We can do this with the help of a Random Number Generator from NumPy.
Then we plot it with the help of Matplotlib. Red families are shown as Red Triangles and Blue
families are shown as Blue Squares.
Then we can plot it with the help of Matplotlib. Red neighbours are shown as Red Triangles and Blue
neighbours are shown as Blue Squares.
@code{.py}
import cv2 as cv
import numpy as np
@@ -80,36 +74,36 @@ import matplotlib.pyplot as plt
# Feature set containing (x,y) values of 25 known/training data
trainData = np.random.randint(0,100,(25,2)).astype(np.float32)
# Labels each one either Red or Blue with numbers 0 and 1
# Label each one either Red or Blue with numbers 0 and 1
responses = np.random.randint(0,2,(25,1)).astype(np.float32)
# Take Red families and plot them
# Take Red neighbours and plot them
red = trainData[responses.ravel()==0]
plt.scatter(red[:,0],red[:,1],80,'r','^')
# Take Blue families and plot them
# Take Blue neighbours and plot them
blue = trainData[responses.ravel()==1]
plt.scatter(blue[:,0],blue[:,1],80,'b','s')
plt.show()
@endcode
You will get something similar to our first image. Since you are using random number generator, you
will be getting different data each time you run the code.
You will get something similar to our first image. Since you are using a random number generator, you
will get different data each time you run the code.
Next initiate the kNN algorithm and pass the trainData and responses to train the kNN (It constructs
a search tree).
Next initiate the kNN algorithm and pass the trainData and responses to train the kNN. (Underneath the hood, it constructs
a search tree: see the Additional Resources section below for more information on this.)
Then we will bring one new-comer and classify him to a family with the help of kNN in OpenCV. Before
going to kNN, we need to know something on our test data (data of new comers). Our data should be a
Then we will bring one new-comer and classify him as belonging to a family with the help of kNN in OpenCV. Before
running kNN, we need to know something about our test data (data of new comers). Our data should be a
floating point array with size \f$number \; of \; testdata \times number \; of \; features\f$. Then we
find the nearest neighbours of new-comer. We can specify how many neighbours we want. It returns:
find the nearest neighbours of the new-comer. We can specify *k*: how many neighbours we want. (Here we used 3.) It returns:
-# The label given to new-comer depending upon the kNN theory we saw earlier. If you want Nearest
Neighbour algorithm, just specify k=1 where k is the number of neighbours.
2. The labels of k-Nearest Neighbours.
3. Corresponding distances from new-comer to each nearest neighbour.
1. The label given to the new-comer depending upon the kNN theory we saw earlier. If you want the *Nearest
Neighbour* algorithm, just specify k=1.
2. The labels of the k-Nearest Neighbours.
3. The corresponding distances from the new-comer to each nearest neighbour.
So let's see how it works. New comer is marked in green color.
So let's see how it works. The new-comer is marked in green.
@code{.py}
newcomer = np.random.randint(0,100,(1,2)).astype(np.float32)
plt.scatter(newcomer[:,0],newcomer[:,1],80,'g','o')
@@ -124,21 +118,21 @@ print( "distance: {}\n".format(dist) )
plt.show()
@endcode
I got the result as follows:
I got the following results:
@code{.py}
result: [[ 1.]]
neighbours: [[ 1. 1. 1.]]
distance: [[ 53. 58. 61.]]
@endcode
It says our new-comer got 3 neighbours, all from Blue family. Therefore, he is labelled as Blue
family. It is obvious from plot below:
It says that our new-comer's 3 nearest neighbours are all from the Blue family. Therefore, he is labelled as part of the Blue
family. It is obvious from the plot below:
![image](images/knn_simple.png)
If you have large number of data, you can just pass it as array. Corresponding results are also
If you have multiple new-comers (test data), you can just pass them as an array. Corresponding results are also
obtained as arrays.
@code{.py}
# 10 new comers
# 10 new-comers
newcomers = np.random.randint(0,100,(10,2)).astype(np.float32)
ret, results,neighbours,dist = knn.findNearest(newcomer, 3)
# The results also will contain 10 labels.
@@ -146,8 +140,11 @@ ret, results,neighbours,dist = knn.findNearest(newcomer, 3)
Additional Resources
--------------------
-# [NPTEL notes on Pattern Recognition, Chapter
11](http://www.nptel.iitm.ac.in/courses/106108057/12)
1. [NPTEL notes on Pattern Recognition, Chapter
11](https://nptel.ac.in/courses/106/108/106108057/)
2. [Wikipedia article on Nearest neighbor search](https://en.wikipedia.org/wiki/Nearest_neighbor_search)
3. [Wikipedia article on k-d tree](https://en.wikipedia.org/wiki/K-d_tree)
Exercises
---------
1. Try repeating the above with more classes and different choices of k. Does choosing k become harder with more classes in the same 2D feature space?
@@ -83,7 +83,7 @@ Let us define a kernel function \f$K(p,q)\f$ which does a dot product between tw
\begin{aligned}
K(p,q) = \phi(p).\phi(q) &= \phi(p)^T \phi(q) \\
&= (p_{1}^2,p_{2}^2,\sqrt{2} p_1 p_2).(q_{1}^2,q_{2}^2,\sqrt{2} q_1 q_2) \\
&= p_1 q_1 + p_2 q_2 + 2 p_1 q_1 p_2 q_2 \\
&= p_{1}^2 q_{1}^2 + p_{2}^2 q_{2}^2 + 2 p_1 q_1 p_2 q_2 \\
&= (p_1 q_1 + p_2 q_2)^2 \\
\phi(p).\phi(q) &= (p.q)^2
\end{aligned}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Some files were not shown because too many files have changed in this diff Show More