'How to pass image data (byte array OR Texture2D) from Unity to c++ plugin

I have made an OpenCV c++ plugin for unity as shown below:

bool resultShare(unsigned char* data, int width, int height)
{
    Mat img = Mat(height, width, CV_8UC3, data);
    if (img.empty())
    {
        a = false;
    }
    else if (!img.empty())
    {
        a = true;
        namedWindow("Image", WINDOW_NORMAL);
        imshow("Image", img);
        waitKey(0);
    }


    return a;
}

But I don't know how to pass Image from unity to that C++ plugin I have tried many things but I am not able to understand the pointers in c# unsafe, fixed, etc ... Please help me to solve this problem!!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source