Commit ef768e00 LN

磁盘空间大于5G时才保存皮带线图片

1 个父辈 d26cf840
......@@ -93,15 +93,15 @@ dMinorStep 步进,默认1.0。
}
string date = cameraName.Trim().Replace('_', '-') + "-" + DateTime.Now.ToString("yyyyMMdd-HHmmss") + DateTime.Now.Millisecond;
string imageName = date + ".bmp";
if (SaveImage)
{
string path = "D:\\image\\"+ cameraName + "\\SourceImg\\";
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
bitmap.Save(path + imageName, ImageFormat.Bmp);
}
//if (SaveImage)
//{
// string path = "D:\\image\\"+ cameraName + "\\SourceImg\\";
// if (!Directory.Exists(path))
// {
// Directory.CreateDirectory(path);
// }
// bitmap.Save(path + imageName, ImageFormat.Bmp);
//}
EyemImage image = eyemCvtToEyemImage(bitmap);
//绿色分割模型
EyemHSVModel tpHsvModel = new EyemHSVModel();
......@@ -145,12 +145,35 @@ dMinorStep 步进,默认1.0。
Bitmap dstBitmap = eyemCvtToBitmap(tpDstImg);
if (dstBitmap != null && SaveImage)
{
string path = "D:\\image\\" + cameraName + "\\ResOut\\";
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
dstBitmap.Save(path + imageName, ImageFormat.Bmp);
//两个工位只有一个料盘时才保存图片
//bool save = false;
//if (ipResults != null && ipResults.Length == 2)
//{
// if ((ipResults[0] == 0) || (ipResults[0] == 1))
// {
// save = true;
// }
// else if ((ipResults[0] == 1) || (ipResults[0] == 0))
// {
// save = true;
// }
//}
//else
//{
// save = true;
//}
//if (save)
//{
string path = "D:\\image\\" + cameraName + "\\ResOut\\";
//if (!Directory.Exists(path))
//{
// Directory.CreateDirectory(path);
//}
if (canSavePic(path))
{
dstBitmap.Save(path + imageName, ImageFormat.Jpeg);
}
//}
}
//释放资源
Marshal.FreeHGlobal(hGlobal);
......@@ -162,6 +185,42 @@ dMinorStep 步进,默认1.0。
return ipResults;
}
public static bool canSavePic(string path ="")
{
if (path == "")
{
path = "D:\\image\\ResOut\\";
}
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
string volume = path.Substring(0, path.IndexOf(':'));
long freespace = GetHardDiskSpace(volume);
int zhao =(int)( freespace / 1024);
if (zhao < 5)
{
LogUtil.error(volume + "盘剩余空间:" + freespace + "M, 不再保存料盘图片");
return false;
}
return true;
}
//单位MB
private static long GetHardDiskSpace(string str_HardDiskName)
{
long totalSize = 0;
str_HardDiskName = str_HardDiskName + ":\\";
System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives();
foreach (System.IO.DriveInfo drive in drives)
{
if (drive.Name == str_HardDiskName)
{
totalSize = drive.TotalFreeSpace / (1024 * 1024);
}
}
return totalSize;
}
public static EyemImage eyemCvtToEyemImage(Bitmap bitmap)
{
EyemImage tpImage = new EyemImage();
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!