因为太多的博客并没有解决pythonnet指针传图问题,本文是自己学习后加入自己深入理解的总结记录,方便自己以后查看。
不通过外部库从C#传图给python,从python传图给C#
1、c#通过指针传输图片和接受图片
public static ICogImage visiontool_predict(ICogImage image1, ICogImage image2, ICogImage image3)
{
try
{
using (Py.GIL())
{
#region 指针传图(方式一,正在更新直接转换内存格式这边直接处理图像)
CogImage8Grey bimage = (CogImage8Grey)image1;
CogImage8Grey gimage = (CogImage8Grey)image2;
CogImage8Grey rimage = (CogImage8Grey)image3;
var blue = bimage.Get8GreyPixelMemory(Cognex.VisionPro.CogImageDataModeConstants.Read, 0, 0, bimage.Width, bimage.Height).Scan0;
var green = gimage.Get8GreyPixelMemory(Cognex.VisionPro.CogImageDataModeConstants.Read, 0, 0, bimage.Width, bimage.Height).Scan0;
var red = rimage.Get8G

最低0.47元/天 解锁文章
1109

被折叠的 条评论
为什么被折叠?



