Realized after testing this implementation that I had the parameter
names inverted on this. Since they are both output parameters it doesn't
impact functinality so the smoke test still worked.
This change corrects the name order so that the doc is correct.
This PR adds support for PCACompute via wrapping one of the opencv
versions with this function signature. A smoke test has been added that
calls the wrapped function and verifies that the parameters are being
passed correctly.
In opencv there are four versions with this function signature, I have
chosen to wrap (what I think is) the most common with the most
parameters.
Link to supported functionality now: https://docs.opencv.org/4.x/d2/de8/group__core__array.html#ga4e2073c7311f292a0648f04c37b73781
DetectorParameters struct
TestArucoDetectorParams
Use DetectorParams
DrawDetectedMarkers
TestDrawDetectMarkers
clean up
Remove duplicate Contour2f
test DrawMarker
Dictionary
clean up
clean up
LDFLAGS add -lopencv_aruco453
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()