Skip to content

Tags: AnyVisionltd/gocv

Tags

2.7.0-0

Toggle 2.7.0-0's commit message
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()

2.6.1-0

Toggle 2.6.1-0's commit message
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()

2.5.1-0

Toggle 2.5.1-0's commit message
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()

2.5.0-0

Toggle 2.5.0-0's commit message
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()

v0.27.1-anyvision

Toggle v0.27.1-anyvision's commit message
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()

v0.27.0

Toggle v0.27.0's commit message
release: updates for v0.27.0 release

Signed-off-by: deadprogram <[email protected]>

v0.26.0

Toggle v0.26.0's commit message
docs: update for 0.26.0 release

Signed-off-by: deadprogram <[email protected]>

v0.25.0

Toggle v0.25.0's commit message
release: prepare for v0.25.0

Signed-off-by: deadprogram <[email protected]>