20 Commits

Author SHA1 Message Date
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
chenttuuvv
60c3789d9d Fix webp image decode error (#523)
* imgcodec: Fix webp image decode error
2019-11-02 08:38:12 +01:00
Douglas Dawson
94247f8604 Add Mat profile wrapper in other areas of the library. 2018-11-18 15:22:14 -05:00
Aleksei Pavliukov
81605c16ee Added IMEncodeWithParams function 2018-10-03 21:47:28 +03:00
Ron Evans
1c792c7fd3 test: filling test coverage gaps
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-07-31 11:53:31 +02:00
Denis Makogon
0bf0abe4db Make toByteArray safe for empty byte slices
Closes: #187
2018-05-11 14:43:06 +03:00
William Durand
195a4f9266 Update some doc 2018-03-23 13:38:07 +01:00
jack
dd06165e58 add fileExt type 2018-01-10 12:07:26 +08:00
deadprogram
5c62df893a imgcodecs: add IMDecode function
Signed-off-by: deadprogram <ron@hybridgroup.com>
2017-11-30 12:27:54 +01:00
deadprogram
2b9a2d65b2 build: add AppVeyor build for Windows 2017-11-13 18:52:58 +01: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
339849c34d Make IMEncode test more tolerant of different distro version
Signed-off-by: deadprogram <ron@hybridgroup.com>
2017-10-03 21:19:20 +02:00
deadprogram
c58a8d371d Add tests for imgcodecs IMEncode
Signed-off-by: deadprogram <ron@hybridgroup.com>
2017-10-03 11:47:38 +02:00
deadprogram
61665ab508 Correct file name used by test after replacement
Signed-off-by: deadprogram <ron@hybridgroup.com>
2017-10-03 11:16:20 +02:00
deadprogram
2886b9a5c1 Rename entire package to gocv
Signed-off-by: deadprogram <ron@hybridgroup.com>
2017-10-02 21:24:43 +02:00
deadprogram
f5dc5e85f2 Add some useful constants for loading images with IMRead()
Signed-off-by: deadprogram <ron@hybridgroup.com>
2017-09-28 12:12:32 +02:00
deadprogram
8f0582e7c2 Placeholders for tests
Signed-off-by: deadprogram <ron@hybridgroup.com>
2017-09-21 13:22:19 +02:00