Cannot use set_name method with bytes data (C++ clients)

186 views
Skip to first unread message

Tonson Praphabkul

unread,
Oct 27, 2023, 6:06:03 AM10/27/23
to grpc.io
Hello Everyone

This is the first time I work with c++ gRPC and I got this error when I tried to set the "data" field.

'''

error: no matching function for call to 'helper::Image::set_data(std::vector<unsigned char>&)'

  314 |             image_results->set_data(buffer);

'''


It's okay for another field that were int32.


here is snippet of my photo files


From helper files


message Image {
int32 rows = 1;
int32 cols = 2;
int32 channels = 3;
bytes data = 4;
ImageType type = 5;
}

From my proto files
message InputImages {
repeated helper.Image image = 1;
helper.ImageType image_response_type = 2;
float confThreshold = 3;
float maskThreshold = 4;
int32 camera_id = 5;
helper.Rectangle detection_rect = 6;
}

How I declare buffer
std::vector<uchar> buffer;

The data inside buffer is get from cv::imencode()

Is it's possible to use set_name method or do I need to use another way to send bytes?

Thank you for your attention.





Tonson Praphabkul

unread,
Oct 30, 2023, 7:37:22 AM10/30/23
to grpc.io

I just figure that out, the set_data of bytes require you to specify the size.
Here is the correct way to do this.
image_results->set_data(buffer.data(), buffer.size());
Reply all
Reply to author
Forward
0 new messages