27 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
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
Bart Schuurmans
564be66d23 Change constants and corresponding function signatures to have the correct types (#689)
* Annotate constant in const() blocks with the correct type if they have a value specified. Fixes #686.
2020-06-05 17:32:40 +02: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
Denis Makogon
03087f95c9 Use pointers 2018-05-11 15:10:40 +03: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
Ron Evans
7e9d22565a opencv: update to OpenCV version 3.4.1
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-03-04 18:15:20 +01:00
Ron Evans
b3f4c9d7dd Merge pull request #54 from cnjack/master
add fileExt type
2018-01-10 07:55:57 +01:00
jack
dd06165e58 add fileExt type 2018-01-10 12:07:26 +08:00
deadprogram
152d0b8412 docs: update all OpenCV 3.3.1 references to v3.4.0
Signed-off-by: deadprogram <ron@hybridgroup.com>
2017-12-25 19:01:54 +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
ab994ff6ea Update all references to point to new OpenCV 3.3.1 release
Signed-off-by: deadprogram <ron@hybridgroup.com>
2017-10-26 10:45:09 +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
372a43c80c Improve docs formatting for imgproc.
Signed-off-by: deadprogram <ron@hybridgroup.com>
2017-10-02 18:25:18 +02:00
deadprogram
fbb6ae3402 Improve docs for IMEncode function
Signed-off-by: deadprogram <ron@hybridgroup.com>
2017-10-02 12:42:37 +02: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
e80bcd3cb1 Lots more godoc details with links to OpenCV doc pages
Signed-off-by: deadprogram <ron@hybridgroup.com>
2017-10-02 10:45:53 +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
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