nareshmlx/opencv-pr huggingface dataset:
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame

**Code Changes:**
```diff
@@ -129,7 +129,7 @@ static int toCV(const ov::element::Type &type) {
 static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
     const auto total = mat.total() * mat.channels();
     if (toCV(tensor.get_element_type()) != mat.depth() ||
-        tensor.get_size()               != total ) {
+        tensor.get_size()               != total) {
         std::stringstream ss;
         ss << "Failed to copy data from ov::Tensor to cv::Mat."
            << " Data type or number of elements mismatch."
@@ -151,6 +151,30 @@ static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
```

Review comment:
In the current implementation `roi_mat` may refer to already expired memory since `view` destructed inside `preprocess` function. I can suggest something like that: ``` case cv::GShape::GMAT: { roi_mat = preprocess(ctx->inMat(1), roi, shape); auto roi_mat = preprocess(ctx->inMat(1), roi, shape); copyToOV(roi_mat, input_tensor); break; } case cv::GShape::GFRAME: { auto currentFrame = ctx->inFrame(1); auto view = currentFrame.access(R); roi_mat = preprocess(view, roi, shape); copyToOV(roi_mat, input_tensor); } ```
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame

**Code Changes:**
```diff
@@ -129,7 +129,7 @@ static int toCV(const ov::element::Type &type) {
 static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
     const auto total = mat.total() * mat.channels();
     if (toCV(tensor.get_element_type()) != mat.depth() ||
-        tensor.get_size()               != total ) {
+        tensor.get_size()               != total) {
         std::stringstream ss;
         ss << "Failed to copy data from ov::Tensor to cv::Mat."
            << " Data type or number of elements mismatch."
@@ -151,6 +151,30 @@ static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
```

Review comment:
Sorry if I confused you with previous comments, couldn't catch this case before
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame

**Code Changes:**
```diff
@@ -129,7 +129,7 @@ static int toCV(const ov::element::Type &type) {
 static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
     const auto total = mat.total() * mat.channels();
     if (toCV(tensor.get_element_type()) != mat.depth() ||
-        tensor.get_size()               != total ) {
+        tensor.get_size()               != total) {
         std::stringstream ss;
         ss << "Failed to copy data from ov::Tensor to cv::Mat."
            << " Data type or number of elements mismatch."
@@ -151,6 +151,30 @@ static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
```

Review comment:
Yes, but can we extend `isImage` to handle `GFrameDesc` as well? In that case we wouldn't need to duplicate logic inside `if`.
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame

**Code Changes:**
```diff
@@ -129,7 +129,7 @@ static int toCV(const ov::element::Type &type) {
 static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
     const auto total = mat.total() * mat.channels();
     if (toCV(tensor.get_element_type()) != mat.depth() ||
-        tensor.get_size()               != total ) {
+        tensor.get_size()               != total) {
         std::stringstream ss;
         ss << "Failed to copy data from ov::Tensor to cv::Mat."
            << " Data type or number of elements mismatch."
@@ -151,6 +151,30 @@ static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
```

Review comment:
Maybe it can be wrapped into function as it's being duplicated across all kernels ``` void copyToOV(OVCallContext ctx, uint32_t input_idx, ov::Tensor& out_tensor) ```
**File:** modules/gapi/test/infer/gapi_infer_ov_tests.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame
**Review Line:** 446

**Code Changes:**
```diff
+    comp.apply(cv::gin(frame, roi), cv::gout(m_out_gapi_age, m_out_gapi_gender),
+               cv::compile_args(cv::gapi::networks(pp)));
+
+    validate();
+}
+
+class TestMediaNV12 final: public cv::MediaFrame::IAdapter {
+    cv::Mat m_y;
+    cv::Mat m_uv;
+
+public:
```

Review comment:
Cool! Can we also cover `NV12` test cases?
**File:** modules/gapi/test/infer/gapi_infer_ov_tests.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame
**Review Line:** 489

**Code Changes:**
```diff
+
+    EXPECT_NO_THROW(comp.apply(cv::gin(frame, roi),
+                    cv::gout(m_out_gapi_age, m_out_gapi_gender),
+                    cv::compile_args(cv::gapi::networks(pp))));
+}
+
 // TODO: Make all of tests below parmetrized to avoid code duplication
 TEST_F(TestAgeGenderOV, Infer_Tensor) {
     const auto in_mat = getRandomTensor({1, 3, 62, 62}, CV_32F);
```

Review comment:
``` ./bin/opencv_test_gapi --gtest_filter=*MediaFrameTestAgeGenderOV* CTEST_FULL_OUTPUT OpenCV version: 4.9.0-dev OpenCV VCS version: 4.9.0-152-g17cbb67b34 Build type: Release Compiler: /usr/bin/c++ (ver 9.4.0) Parallel framework: pthreads (nthreads=6) CPU features: SSE SSE2 SSE3 *SSE4.1 *SSE4.2 *FP16 *AVX *AVX2 *AVX512-SKX? Intel(R) IPP version: ippIP AVX2 (l9) 2021.10.1 (-) Dec 6 2023 Intel(R) IPP features code: 0x8000 OpenCL is disabled TEST: Skip tests with tags: 'mem_6gb', 'verylong' Note: Google Test filter = *MediaFrameTestAgeGenderOV* [==========] Running 3 tests from 1 test case. [----------] Global test environment set-up. [----------] 3 tests from MediaFrameTestAgeGenderOV [ RUN ] MediaFrameTestAgeGenderOV.InferMediaInputBGR [ OK ] MediaFrameTestAgeGenderOV.InferMediaInputBGR (434 ms) [ RUN ] MediaFrameTestAgeGenderOV.InferROIGenericMediaInputBGR [ OK ] MediaFrameTestAgeGenderOV.InferROIGenericMediaInputBGR (135 ms) [ RUN ] MediaFrameTestAgeGenderOV.TestMediaNV12AgeGenderOV [ OK ] MediaFrameTestAgeGenderOV.TestMediaNV12AgeGenderOV (5 ms) [----------] 3 tests from MediaFrameTestAgeGenderOV (574 ms total) [----------] Global test environment tear-down [==========] 3 tests from 1 test case ran. (575 ms total) [ PASSED ] 3 tests. ```
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame

**Code Changes:**
```diff
@@ -129,7 +129,7 @@ static int toCV(const ov::element::Type &type) {
 static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
     const auto total = mat.total() * mat.channels();
     if (toCV(tensor.get_element_type()) != mat.depth() ||
-        tensor.get_size()               != total ) {
+        tensor.get_size()               != total) {
         std::stringstream ss;
         ss << "Failed to copy data from ov::Tensor to cv::Mat."
            << " Data type or number of elements mismatch."
@@ -151,6 +151,30 @@ static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
```

Review comment:
Sorry, I do not really get this part ``` roi_mat = preprocess(ctx->inMat(1), roi, shape); auto roi_mat = preprocess(ctx->inMat(1), roi, shape); ```
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame
**Review Line:** 135

**Code Changes:**
```diff
     if (toCV(tensor.get_element_type()) != mat.depth() ||
-        tensor.get_size()               != total ) {
+        tensor.get_size()               != total) {
         std::stringstream ss;
         ss << "Failed to copy data from ov::Tensor to cv::Mat."
            << " Data type or number of elements mismatch."
@@ -151,6 +151,30 @@ static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
     }
 }
 
+cv::Mat wrapOV(const cv::MediaFrame::View& view,
```

Review comment:
But we also check `number` of elements, didn't we?
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame

**Code Changes:**
```diff
@@ -129,7 +129,7 @@ static int toCV(const ov::element::Type &type) {
 static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
     const auto total = mat.total() * mat.channels();
     if (toCV(tensor.get_element_type()) != mat.depth() ||
-        tensor.get_size()               != total ) {
+        tensor.get_size()               != total) {
         std::stringstream ss;
         ss << "Failed to copy data from ov::Tensor to cv::Mat."
            << " Data type or number of elements mismatch."
@@ -151,6 +151,30 @@ static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
```

Review comment:
`default` - error unknown format
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame

**Code Changes:**
```diff
@@ -129,7 +129,7 @@ static int toCV(const ov::element::Type &type) {
 static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
     const auto total = mat.total() * mat.channels();
     if (toCV(tensor.get_element_type()) != mat.depth() ||
-        tensor.get_size()               != total ) {
+        tensor.get_size()               != total) {
         std::stringstream ss;
         ss << "Failed to copy data from ov::Tensor to cv::Mat."
            << " Data type or number of elements mismatch."
@@ -151,6 +151,30 @@ static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
```

Review comment:
I don't think we need it at least now, because we always copy data from mat to tensor instead of wrap the memory
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame

**Code Changes:**
```diff
@@ -129,7 +129,7 @@ static int toCV(const ov::element::Type &type) {
 static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
     const auto total = mat.total() * mat.channels();
     if (toCV(tensor.get_element_type()) != mat.depth() ||
-        tensor.get_size()               != total ) {
+        tensor.get_size()               != total) {
         std::stringstream ss;
         ss << "Failed to copy data from ov::Tensor to cv::Mat."
            << " Data type or number of elements mismatch."
@@ -151,6 +151,30 @@ static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
```

Review comment:
Nitpick: it can be similar to line above: ``` copyToOV(ctx->inFrame(input_idx), tensor)); ``` In this case the brackets for `case` aren't even needed
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame
**Review Line:** 814

**Code Changes:**
```diff
+        default:
+            GAPI_Assert("Unsupported input shape for OV backend");
+    }
+}
+
 static bool isImage(const cv::GMatDesc &desc,
                     const ::ov::Shape  &model_shape) {
     return (model_shape.size() == 4u)                      &&
@@ -739,6 +820,16 @@ static bool isImage(const cv::GMatDesc &desc,
            (desc.depth == CV_8U);
 }
```

Review comment:
I suppose `isImage` can be extended to accept `GMetaArg` and if it's `GFrameDesc` returns true, otherwise assert if it's `GMatDesc` and use the checks below
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame

**Code Changes:**
```diff
@@ -129,7 +129,7 @@ static int toCV(const ov::element::Type &type) {
 static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
     const auto total = mat.total() * mat.channels();
     if (toCV(tensor.get_element_type()) != mat.depth() ||
-        tensor.get_size()               != total ) {
+        tensor.get_size()               != total) {
         std::stringstream ss;
         ss << "Failed to copy data from ov::Tensor to cv::Mat."
            << " Data type or number of elements mismatch."
@@ -151,6 +151,30 @@ static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
```

Review comment:
Yes - `copyToOV` is fine, but `wrapOV` is still there, is it used somewhere else?
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame

**Code Changes:**
```diff
@@ -129,7 +129,7 @@ static int toCV(const ov::element::Type &type) {
 static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
     const auto total = mat.total() * mat.channels();
     if (toCV(tensor.get_element_type()) != mat.depth() ||
-        tensor.get_size()               != total ) {
+        tensor.get_size()               != total) {
         std::stringstream ss;
         ss << "Failed to copy data from ov::Tensor to cv::Mat."
            << " Data type or number of elements mismatch."
@@ -151,6 +151,30 @@ static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
```

Review comment:
I guess it's not needed, since we transform `NV12` to `BGR` in runtime and don't pass `NV12` to `OpenVINO` at all
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame

**Code Changes:**
```diff
@@ -129,7 +129,7 @@ static int toCV(const ov::element::Type &type) {
 static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
     const auto total = mat.total() * mat.channels();
     if (toCV(tensor.get_element_type()) != mat.depth() ||
-        tensor.get_size()               != total ) {
+        tensor.get_size()               != total) {
         std::stringstream ss;
         ss << "Failed to copy data from ov::Tensor to cv::Mat."
            << " Data type or number of elements mismatch."
@@ -151,6 +151,30 @@ static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
```

Review comment:
Is `tensor_shape` is used somewhere?
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame

**Code Changes:**
```diff
@@ -129,7 +129,7 @@ static int toCV(const ov::element::Type &type) {
 static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
     const auto total = mat.total() * mat.channels();
     if (toCV(tensor.get_element_type()) != mat.depth() ||
-        tensor.get_size()               != total ) {
+        tensor.get_size()               != total) {
         std::stringstream ss;
         ss << "Failed to copy data from ov::Tensor to cv::Mat."
            << " Data type or number of elements mismatch."
@@ -151,6 +151,30 @@ static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
```

Review comment:
What about `GFrameDesc`? This is the exact point of handling both `GMatDesc` / `GFrameDesc` (they're part of `GMetaArg`) in `isImage` function. E.g ``` static bool isImage(const cv::GMetaArg& meta, const ov::Shape& shape) { if (cv::util::holds_alternative<GFrameDesc>(meta)) { return true; } GAPI_Assert(cv::util::holds_alternative<GMatDesc>(meta)); auto matdesc = cv::util::get<GMatDesc>(meta); return isImage(matdesc, shape); } ```
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame
**Review Line:** 1349

**Code Changes:**
```diff
 
         const auto &input_name_0 = uu.params.input_names.front();
         const auto &mm_0 = in_metas[0u];
-        const auto &matdesc = cv::util::get<cv::GMatDesc>(mm_0);
+
+        if (!(cv::util::holds_alternative<cv::GMatDesc>(mm_0) ||
+              cv::util::holds_alternative<cv::GFrameDesc>(mm_0))) {
+            util::throw_error(std::runtime_error(
+                        "OV Backend: Unsupported input meta"
+                        " for 0th argument in OV backend"));
+        }
```

Review comment:
Looks we don't need these checks once `isImage` handles everything inside
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame

**Code Changes:**
```diff
@@ -129,7 +129,7 @@ static int toCV(const ov::element::Type &type) {
 static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
     const auto total = mat.total() * mat.channels();
     if (toCV(tensor.get_element_type()) != mat.depth() ||
-        tensor.get_size()               != total ) {
+        tensor.get_size()               != total) {
         std::stringstream ss;
         ss << "Failed to copy data from ov::Tensor to cv::Mat."
            << " Data type or number of elements mismatch."
@@ -151,6 +151,30 @@ static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
```

Review comment:
If `isImage` handles `GFrameDesc` It can be simplified like this: ``` auto prec = isMat ? cv::util::get<cv::GMatDesc>(input_meta).depth : CV_8U; // Here is isImage handles GFrameDesc as well if isImage(input_meta) { const auto size = isMat ? cv::util::get<cv::GMatDesc>(input_meta).size : cv::util::get<cv:GFrameDesc>(input_meta).size ... if (!disable_img_resize) { input_info.tensor().set_spatial_static_shape(size.height, size.width) } ... ss << "..." << ( isMat ? cv::util::get<cv::GMatDesc>(input_meta) : cv::util::get<cv:GFrameDesc>(input_meta) ) << "..." ... } ```
**File:** modules/gapi/test/infer/gapi_infer_ov_tests.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame

**Code Changes:**
```diff
@@ -319,8 +319,174 @@ struct TestAgeGenderListOV : public BaseAgeGenderOV {
     }
 };
 
+class TestMediaBGR final: public cv::MediaFrame::IAdapter {
+    cv::Mat m_mat;
+    using Cb = cv::MediaFrame::View::Callback;
+    Cb m_cb;
+
+public:
```

Review comment:
`NV12` for `OV` backend doesn't have version limitations, it's only problem of `IE` backend
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame

**Code Changes:**
```diff
@@ -129,7 +129,7 @@ static int toCV(const ov::element::Type &type) {
 static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
     const auto total = mat.total() * mat.channels();
     if (toCV(tensor.get_element_type()) != mat.depth() ||
-        tensor.get_size()               != total ) {
+        tensor.get_size()               != total) {
         std::stringstream ss;
         ss << "Failed to copy data from ov::Tensor to cv::Mat."
            << " Data type or number of elements mismatch."
@@ -151,6 +151,30 @@ static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
```

Review comment:
once `view` is destructed, the mat returned by `preprocess` will be invalid :(
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame

**Code Changes:**
```diff
@@ -129,7 +129,7 @@ static int toCV(const ov::element::Type &type) {
 static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
     const auto total = mat.total() * mat.channels();
     if (toCV(tensor.get_element_type()) != mat.depth() ||
-        tensor.get_size()               != total ) {
+        tensor.get_size()               != total) {
         std::stringstream ss;
         ss << "Failed to copy data from ov::Tensor to cv::Mat."
            << " Data type or number of elements mismatch."
@@ -151,6 +151,30 @@ static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
```

Review comment:
Sorry, it's typo: ``` case cv::GShape::GMAT: { auto roi_mat = preprocess(ctx->inMat(1), roi, shape); copyToOV(roi_mat, input_tensor); break; } case cv::GShape::GFRAME: { auto currentFrame = ctx->inFrame(1); auto view = currentFrame.access(R); roi_mat = preprocess(view, roi, shape); copyToOV(roi_mat, input_tensor); } ```
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame

**Code Changes:**
```diff
@@ -129,7 +129,7 @@ static int toCV(const ov::element::Type &type) {
 static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
     const auto total = mat.total() * mat.channels();
     if (toCV(tensor.get_element_type()) != mat.depth() ||
-        tensor.get_size()               != total ) {
+        tensor.get_size()               != total) {
         std::stringstream ss;
         ss << "Failed to copy data from ov::Tensor to cv::Mat."
            << " Data type or number of elements mismatch."
@@ -151,6 +151,30 @@ static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
```

Review comment:
Maybe this could help us? From the `InferROI::run` it could be something like this: ``` preprocess_and_copy(ctx, 1, roi, shape, input_tensor); ``` and implementation might be similar to this: ``` static cv::Mat preprocess_and_copy(std::shared_ptr<OVCallContext> ctx, uint32_t input_idx, const cv::Rect &roi, const ::ov::Shape &model_shape, ov::Tensor& tensor) { switch (ctx->inShape(input_idx)) { case cv::GShape::GMAT: { auto roi_mat = preprocess(ctx->inMat(1), roi, shape); copyToOV(roi_mat, tensor); break; } case cv::GShape::GFRAME: { auto currentFrame = ctx->inFrame(1); auto view = currentFrame.access(R); roi_mat = preprocess(view, currentFrame.desc(), roi, shape); copyToOV(roi_mat, input_tensor); } default: GAPI_Assert("Unsupported input shape for OV backend"); } } ``` But in this case the `preprocess` for `Frame` should accept `view` (not `MediFrame`) ``` cv::Mat preprocess(MediaFrame::View& view, const cv::GFrameDesc& desc, const cv::Rect& roi, const ::ov::Shape &model_shape) { return preprocess(wrapOV(view, desc), roi, model_shape); } ```
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame
**Review Line:** 935

**Code Changes:**
```diff
-        if (isImage(matdesc, input_shape)) {
+        auto isMat = cv::util::holds_alternative<cv::GMatDesc>(input_meta);
+        auto prec  = isMat ? cv::util::get<cv::GMatDesc>(input_meta).depth : CV_8U;
+        m_ppp.input(input_name).tensor().set_element_type(toOV(prec));
+
+        const auto &matdesc   = isMat ? cv::util::get<cv::GMatDesc>(input_meta) : cv::GMatDesc();
+        const auto &framedesc = !isMat ? cv::util::get<cv::GFrameDesc>(input_meta) : cv::GFrameDesc();
+        if (isImage(input_meta, input_shape)) {
             // NB: Image case - all necessary preprocessng is configured automatically.
             GAPI_LOG_DEBUG(NULL, "OV Backend: Input: \"" << input_name << "\" is image.");
-            if (explicit_in_tensor_layout &&
```

Review comment:
Instead of `matdesc` and `framedesc` you can simply do: ``` << " is not compatible with input data " << isMat ? cv::util::get<GMatDesc>(input_meta) : cv::util::get<GFrameDesc>(input_meta) << ... ```
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame

**Code Changes:**
```diff
@@ -129,7 +129,7 @@ static int toCV(const ov::element::Type &type) {
 static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
     const auto total = mat.total() * mat.channels();
     if (toCV(tensor.get_element_type()) != mat.depth() ||
-        tensor.get_size()               != total ) {
+        tensor.get_size()               != total) {
         std::stringstream ss;
         ss << "Failed to copy data from ov::Tensor to cv::Mat."
            << " Data type or number of elements mismatch."
@@ -151,6 +151,30 @@ static void copyFromOV(const ov::Tensor &tensor, cv::Mat &mat) {
```

Review comment:
is it used anywhere?