如何反序列化opencv图像,从c++发送到python 3?

Bor*_*ink 5 c++ python opencv

我正在开发一个 python3 应用程序,我需要从由 C++ 应用程序序列化并存储在 protobuf 消息中的数据创建 openCV 图像。我只能访问包含以下数据的结构:

message Image {
    uint32          rows            =1;
    uint32          cols            =2;
    int32           elemType        =3; //openCV type (ex: CV_8U)
    int32           elemSize        =4;
    bytes           data            =5;
}
Run Code Online (Sandbox Code Playgroud)

我已经尝试过这样做,通过 numpy 首先创建一个数组,但我认为我做错了......

这是一些代码,img我之前提到的结构在哪里:

message Image {
    uint32          rows            =1;
    uint32          cols            =2;
    int32           elemType        =3; //openCV type (ex: CV_8U)
    int32           elemSize        =4;
    bytes           data            =5;
}
Run Code Online (Sandbox Code Playgroud)

我想跳过这里完成的奇怪的解析,但是如何呢?我不知道...(我对 python、openCV 和 stackoverflow 很陌生,所以请友善^^)