16 Commits

Author SHA1 Message Date
deadprogram
bd83700f33 feature: return error from calls to OpenCV functions. The error shows the OpenCV exception description
from the exception caught.

Signed-off-by: deadprogram <ron@hybridgroup.com>
2025-03-18 11:04:10 -03:00
deadprogram
a9fec5bda3 feature: add exception handling function and try/catch blocks
Signed-off-by: deadprogram <ron@hybridgroup.com>
2025-03-18 11:04:10 -03:00
diegohce
0ba962c4a2 added immultiread support 2024-08-14 12:17:31 +02:00
Niklas Hansson
cd9897f55d imgcodecs: Add IMDecodeIntoMat to reduce heap allocations (#1035)
* imgcodecs: add IMDecodeIntoMat which allows to imdecode into existing Mat for performance
2023-01-02 12:23:04 +01:00
Solganik Alexander
5dbdee404a imencode: optimize IMEncode avoiding multiple data copies.
Currently IMEncode implemented the following way:
1) In Image_IMEncode std::vector is allocated and filled by cv::imencode
2) In Image_IMEncode function toByteArray allocated another native array
and copies the data from the vector
3) In IMEncode the result of Image_IMEncode is further copied to golang
allocated byte array.

Hence there are 2 additional copies of the data for each call to
IMEncode.
This is highly inefficient, especially if this needs to be performed
frequently.

The solution is to avoid copies altogether (though with a slight API
cost).
First we introduce NativeByteBuffer struct which is just a wrapper for
std::vector. Note that it is hard-coded 24 bytes (std::vector is 3
pointers of data, and this will never change as this will force
recompilation of probably every existing c++ application).

Second We call Image_IMEncode with this "preallocated" and
pre-initialied std::vector.

Finally the "func (buffer *NativeByteBuffer) GetBytes() []byte" function
returns a hand-made slice from the underlying std::vector buffer.

Note that we both provide a "Close" function and register "finalizer" to
clear the native buffer when NativeByteBuffer goes out of scope.

Usage Example:

buf, err := IMEncode(PNGFileExt, img)
defer buf.Close()
bytes := buf.GetBytes()
2021-07-12 11:10:02 +02:00
Ron Evans
e9e88eb07d imgcodecs: optimize copy of data used for IMDecode method
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-12-23 09:45:47 +01:00
chenttuuvv
60c3789d9d Fix webp image decode error (#523)
* imgcodec: Fix webp image decode error
2019-11-02 08:38:12 +01:00
Aleksei Pavliukov
81605c16ee Added IMEncodeWithParams function 2018-10-03 21:47:28 +03:00
William Durand
e0a309f4a8 Astyle cpp/h files 2018-03-15 11:26:51 +01:00
deadprogram
5c62df893a imgcodecs: add IMDecode function
Signed-off-by: deadprogram <ron@hybridgroup.com>
2017-11-30 12:27:54 +01:00
Sergey Lutskanu
620b6f3eac Fixed possible looping out of compression parameters length 2017-10-31 12:57:53 +03:00
Sergey Lutskanu
acffbad748 Make dedicated function to run cv::imwrite with compression parameters 2017-10-30 15:31:36 +03:00
Sergey Lutskanu
ee95fc0055 Add image compression flags for gocv.IMWrite 2017-10-28 13:03:08 +03:00
deadprogram
29041e2c7e Add IMEncode to be able to perform in-memory decoding
Signed-off-by: deadprogram <ron@hybridgroup.com>
2017-10-02 12:33:24 +02:00
deadprogram
3dddcbe528 Can save an image from Mat to disk
Signed-off-by: deadprogram <ron@hybridgroup.com>
2017-09-22 20:32:49 +02:00
deadprogram
ea376b34cd Can load a file into a Mat, and display it in the Window
Signed-off-by: deadprogram <ron@hybridgroup.com>
2017-09-20 04:19:42 +02:00