1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Merge pull request #25055 from dmatveev:dm/value_initialized_gmat

G-API: A quick value-initialization support GMat #25055

This PR enables `GMat` objects to be value-initialized in the same way as it was done for `GScalar`s (and, possibly, other types).

- Added some helper methods in backends to distinguish if a certain G-type value initialization is supported or not;
- Added tests, including negative.

Where it is needed:

- Further extension of the OVCV backend (#24379 - will be refreshed soon);
- Further experiments with DNN module;
- Further experiments with "G-API behind UMat" sort of aggregation.

In the current form, PR can be reviewed & merged (@TolyaTalamanov please have a look)

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Dmitry Matveev
2024-03-06 14:15:49 +00:00
committed by GitHub
parent 0e524ee95a
commit f174363f60
14 changed files with 208 additions and 13 deletions
@@ -77,6 +77,18 @@ public:
*/
GAPI_WRAP GMat(); // Empty constructor
/**
* @brief Constructs a value-initialized GMat
*
* GMat may be associated with a buffer at graph construction time.
* It is useful when some operation has a Mat input which doesn't
* change during the program execution, and is set only once.
* In this case, there's no need to declare such GMat as graph input.
*
* @param m a cv::Mat buffer to associate with this GMat object.
*/
GAPI_WRAP explicit GMat(cv::Mat m); // Value-initialization constructor
/// @private
GMat(const GNode &n, std::size_t out); // Operation result constructor
/// @private
@@ -54,12 +54,11 @@ public:
/**
* @brief Constructs a value-initialized GScalar
*
* In contrast with GMat (which can be either an explicit graph input
* or a result of some operation), GScalars may have their values
* be associated at graph construction time. It is useful when
* some operation has a GScalar input which doesn't change during
* the program execution, and is set only once. In this case,
* there is no need to declare such GScalar as a graph input.
* GScalars may have their values be associated at graph
* construction time. It is useful when some operation has a
* GScalar input which doesn't change during the program
* execution, and is set only once. In this case, there is no need
* to declare such GScalar as a graph input.
*
* @note The value of GScalar may be overwritten by assigning some
* other GScalar to the object using `operator=` -- on the