C#将byte[]传入C/C++库

C/C++原文件

typedef unsigned char uint8_t;

int detect_image_bytes(uint8_t* bytes, bbox_t_container &container)
{
	std::vector<bbox_t> detection = detector->detect_bytes(bytes);
	for (size_t i = 0; i < detection.size() && i < C_SHARP_MAX_OBJECTS; ++i)
		container.candidates[i] = detection[i];
	return detection.size();
}

C#引入库

[DllImport(YoloLibraryName, EntryPoint = "detect_image_bytes")]
private static extern int DetectImage_bytes(byte[] bytes, ref BboxContainer container, float threshold);

C#调用函数

var count = DetectImage_bytes(bytes, ref container, threshold);

你可能感兴趣的:(图像识别)