# Get size of cv::GMat

**URL:** <https://forum.opencv.org/t/get-size-of-cv-gmat/5756>\
**Category:** C++\
**Tags:** gapi\
**Created:** [October 21, 2021, 8:16am UTC](https://forum.opencv.org/t/get-size-of-cv-gmat/5756 "2021-10-21T08:16:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![carter54](https://avatars.discourse-cdn.com/v4/letter/c/3ec8ea/32.png) [@carter54](https://forum.opencv.org/u/carter54)\
**Post date:** [October 21, 2021, 8:16am UTC](https://forum.opencv.org/t/get-size-of-cv-gmat/5756/1 "2021-10-21T08:16:21Z")

</div>

Hi~ I am a startter of g-API. This question might be very simple to you.

for a cv::Mat A, we can easily get the size of A by A.size(), A.cols, A.rows. Is there a similar API for a cv::GMat object?

for example, I can resize B with the size of A

```auto
cv::Mat A = cv::imread(...);
cv::Mat B = cv::imread(...);
cv::resize(B, B, A.size());

```

How can get the size of A if I want to use g-API?

Thx in advance!

---

<div class="post-metadata">

**Author:** ![dmitryma](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/dmitryma/32/3536_2.png) [@dmitryma](https://forum.opencv.org/u/dmitryma)\
**Post date:** [October 21, 2021, 11:52am UTC](https://forum.opencv.org/t/get-size-of-cv-gmat/5756/2 "2021-10-21T11:52:29Z")

</div>

Hi @carter54

No, there’s no way to do that. At the point when you define a Graph (and so, operate with `GMat` and other objects), there’s no any image information associated with it.

The image information appears when the graph is compiled - via `compile()`, `compileStreaming()` or implicitly via `.apply()` - and the image information is passed in.

The idea behind this is that graph is optimized to manage a certain image resolution. Sometimes it can be changed with `.reshape()`, but note it only applies to a compiled graph object (where `GMat` & etc are already optimized out - as those objects are only used to _construct_ the graph).

There are places, still, where you can access information about the `GMat` dimensions during the graph compile process (this is the stage where this information is known). The Operation’s `outMeta()` callback is one of those, if you’re writing your own Operations.
