nareshmlx/opencv-pr huggingface dataset:
**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:
``` opencv_test_gapi --gtest_filter=*MediaFrameTestAgeGenderOV* CTEST_FULL_OUTPUT OpenCV version: 4.9.0-dev OpenCV VCS version: 4.9.0-106-gbde2400e29-dirty 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.0 (-) Sep 18 2023 Intel(R) IPP features code: 0x8000 OpenCL is disabled TEST: Skip tests with tags: 'mem_6gb', 'verylong' Note: Google Test filter = *MediaFrameTestAgeGenderOV* [==========] Running 2 tests from 1 test case. [----------] Global test environment set-up. [----------] 2 tests from MediaFrameTestAgeGenderOV [ RUN ] MediaFrameTestAgeGenderOV.InferMediaInputBGR [ OK ] MediaFrameTestAgeGenderOV.InferMediaInputBGR (118 ms) [ RUN ] MediaFrameTestAgeGenderOV.InferROIGenericMediaInputBGR [ OK ] MediaFrameTestAgeGenderOV.InferROIGenericMediaInputBGR (72 ms) [----------] 2 tests from MediaFrameTestAgeGenderOV (190 ms total) [----------] Global test environment tear-down [==========] 2 tests from 1 test case ran. (190 ms total) [ PASSED ] 2 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:
I'd leave it as it was previously, since it doesn't block MediaFrame integration. Let's change in further PR's with dynamic shapes support
**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:
And this, and all 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:
Don't think we need `inline` in cpp file, perhaps it's typo from `giebackend`
**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: Error message format is a little bit different: https://github.com/opencv/opencv/blob/17cbb67b343eca0f959f6cafdb2e57b56429fd3b/modules/gapi/src/backends/ov/govbackend.cpp#L91
**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:
`view` - singular form
**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 `wrapOV` at this point since we always copy data to `infer_request` (it was different in `IE` backend though) I propose we have single function instead, at least so far: ``` static void copyToOv(const cv::MediaFrame& frame, ov::Tensor& tensor) { cv::Mat mat; auto view frame.access(R); // Keep view alive until copy data to tensor switch (frame.desc().fmt) { // Create a mat a top of MediaFrame memory (no copy so far) } copyToOV(mat, tensor) // here is already deep-copy // ... and and this point view may die, memory already copied } ```
**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:
perhaps we need `to_ov(MediaFrame, ov::Tensor)` for tests as well
**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:
No need to keep views if we decided to copy data from MediaFrame to ov::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:
Ok, you're right, for that case we need `wrapOV` indeed. But still we can do the deep copy right after and don't keep `view`'s in context. ``` const auto view = frame.access(R); auto mat = wrapOV(view, frame.desc()) preprocess(mat, roi, model_shape); // ... I guess it's fine if "view" will die at this point ```
**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:
Based on the comment below, it can be: ``` static void copyToOv(const cv::MediaFrame& frame, ov::Tensor& tensor) { auto view frame.access(R); // Keep view alive until copy data to tensor auto mat = wrapOV(view, frame.desc()); // <- we basically just wrapped "switch" into wrapOV function copyToOV(mat, tensor) // here is already deep-copy // ... and and this point view may die, memory already copied } ```
**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:
Ok, probably the logic inside backend is really tricky to understand. 1. The point is that when we have `GFrameDesc` is should always fall into `isImage` category, since `MediaFrame` is type to represent an `image` so this function can be extended to accept `GMetaArg` and if it holds `GFrameDesc` returns `true` otherwise asserts it's `GMatDesc` and fall to already existing implementation. 2. `PrePostProcWrapper` already accepts `GMetaArg` in its methods so we just need to handle it properly. If we have `GFrameDesc` instead `GMatDesc` let's assume our data type is `U8` and `width` / `height` we can access
**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:
We can serialize `GMetaArg` to string like this: ``` switch (desc.index()) { case cv::GMetaArg::index_of<cv::GFrameDesc>(): desc_str << cv::util::get<cv::GFrameDesc>(desc); break; case cv::GMetaArg::index_of<cv::GMatDesc>(): desc_str << cv::util::get<cv::GMatDesc>(desc); break; } std::stringstream ss; ... ss << " is not compatible with input data " << desc_str << " for layer \""; ```
**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:
Actually we don't need this, in current implementation if `MediaFrame` is `NV12` we just convert it to `BGR` and copy to tensor which is fine. Propose we remove `cfgColorFormat` so far and `ifdef`
**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:
Added for NV12, so haven't tested it yet
**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:
As I saw, `<< framedesc <<` works fine here as well.
**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:
> The point is that when we have GFrameDesc is should always fall into isImage category, since MediaFrame is type to represent an image so this function can be extended to accept GMetaArg and if it holds GFrameDesc returns true otherwise asserts it's GMatDesc and fall to already existing implementation. That's what I kept for `MediaFrame`. If you take a look at the `else if (cv::util::holds_alternative<cv::GFrameDesc>(input_meta)) {` branch you'll see the logic that aligns with `isImage` branch from `cv::GMatDesc` case.
**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:
Added a comment about this to the PR description.
**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:
we still need to check number of elements, don't we?
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #24938: G-API OV backend requires cv::MediaFrame
**Review Line:** 154

**Code Changes:**
```diff
            << " 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,
+               const cv::GFrameDesc& desc) {
+    cv::Mat out;
+    switch (desc.fmt) {
+        case cv::MediaFormat::BGR: {
+            out = cv::Mat(desc.size, CV_8UC3, view.ptr[0], view.stride[0]);
```

Review comment:
Looks good, maybe make sense to put `return out` instead of `GAPI_Error`
**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:
hmmm, I thought we already had this function...
**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:
Suggest we don't touch `PartialShape` as part of this PR
**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'm not sure we can replace this one with new implementation
**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, it does, it's just a simple code reorganization to get rid of duplication