上传视觉检测模块
This commit is contained in:
@ -17,23 +17,7 @@ using Newtonsoft.Json;
|
||||
namespace DH.Devices.Vision
|
||||
{
|
||||
|
||||
//public class SegResult
|
||||
//{
|
||||
// public List<Result> SegmentResult;
|
||||
// public class Result
|
||||
// {
|
||||
|
||||
// public double fScore;
|
||||
// public int classId;
|
||||
// public string classname;
|
||||
|
||||
// public double area;
|
||||
// public List<int> rect;
|
||||
|
||||
|
||||
// }
|
||||
|
||||
//}
|
||||
|
||||
|
||||
|
||||
@ -157,7 +141,6 @@ namespace DH.Devices.Vision
|
||||
}
|
||||
|
||||
int iNum = detResult.SegmentResult.Count;
|
||||
int IokNum = 0;
|
||||
for (int ix = 0; ix < iNum; ix++)
|
||||
{
|
||||
var det = detResult.SegmentResult[ix];
|
||||
@ -188,7 +171,7 @@ namespace DH.Devices.Vision
|
||||
{
|
||||
MLResult mlResult = new MLResult();
|
||||
Mat originMat=new Mat() ;
|
||||
Mat tempMat;
|
||||
Mat detectMat;
|
||||
try
|
||||
{
|
||||
if (req.mImage == null)
|
||||
@ -199,26 +182,26 @@ namespace DH.Devices.Vision
|
||||
}
|
||||
|
||||
// resize
|
||||
tempMat = req.mImage;//1ms
|
||||
detectMat = req.mImage;//1ms
|
||||
|
||||
|
||||
|
||||
int iWidth = tempMat.Cols;
|
||||
int iHeight = tempMat.Rows;
|
||||
int iWidth = detectMat.Cols;
|
||||
int iHeight = detectMat.Rows;
|
||||
|
||||
// 如果是单通道图像,转换为三通道 RGB 格式
|
||||
if (tempMat.Channels() == 1)
|
||||
if (detectMat.Channels() == 1)
|
||||
{
|
||||
// 将灰度图像转换为RGB格式(三通道)
|
||||
|
||||
Cv2.CvtColor( tempMat,originMat, ColorConversionCodes.GRAY2BGR);
|
||||
Cv2.CvtColor( detectMat,originMat, ColorConversionCodes.GRAY2BGR);
|
||||
|
||||
}
|
||||
else if (tempMat.Channels() == 3)
|
||||
else if (detectMat.Channels() == 3)
|
||||
{
|
||||
// 如果已经是三通道(BGR),则直接转换为RGB
|
||||
|
||||
Cv2.CvtColor( tempMat,originMat, ColorConversionCodes.BGR2RGB);
|
||||
Cv2.CvtColor( detectMat,originMat, ColorConversionCodes.BGR2RGB);
|
||||
|
||||
}
|
||||
|
||||
@ -250,9 +233,6 @@ namespace DH.Devices.Vision
|
||||
{
|
||||
mlResult.ResultMessage = $"深度学习推理成功,耗时:{sw.ElapsedMilliseconds} ms";
|
||||
|
||||
//Mat maskWeighted = new Mat(iHeight, iWidth, MatType.CV_8UC3, outputByte);
|
||||
|
||||
//mlResult.ResultMap = BitmapConverter.ToBitmap(maskWeighted);//4ms
|
||||
//将字节数组转换为字符串
|
||||
mlResult.ResultMap = originMat.ToBitmap();//4ms
|
||||
string strGet = System.Text.Encoding.Default.GetString(labellist, 0, labellist.Length);
|
||||
@ -261,9 +241,6 @@ namespace DH.Devices.Vision
|
||||
|
||||
ConvertJsonResult(strGet, ref mlResult);
|
||||
|
||||
//maskWeighted?.Dispose();
|
||||
//maskWeighted = null;
|
||||
|
||||
// 解析json字符串
|
||||
return mlResult;
|
||||
}
|
||||
|
Reference in New Issue
Block a user