AOI

 找回密码
 立即注册
查看: 132|回复: 0

路径字符串操作

[复制链接]

123

主题

156

帖子

841

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
841
发表于 5 天前 | 显示全部楼层 |阅读模式
需要构建一个WitiaiPath.lib,当前使用还有些困难
  1. public void WitiaiMain() //Fixed Entry, 所有函数名开头均以[public void]命名
  2. {
  3.     // 不建议用中文,容易乱码
  4.     string s_modelPath = @"D:\BaiduNetdiskDownload\AIOCRProjects";
  5.     string mask = @"D:\BaiduNetdiskDownload\AIOCRProjects\Mask";
  6.     string Image = @"D:\BaiduNetdiskDownload\AIOCRProjects\Image";
  7.     string savepath = @"D:\BaiduNetdiskDownload\AIOCRProjects\Validation\Image";
  8.     ListImageFiles(mask, "png", out Ls_FileList);
  9.     int number = Ls_FileList.Count();
  10.     for(int i=0; i< number; i++)
  11.     {
  12.         string imagepath = Ls_FileList[i];
  13.         TupleSplit(imagepath, "/", out Ls_Substrings);
  14.         TupleLength(Ls_Substrings, out i_Numbers);
  15.         int EndIndex = i_Numbers-1;
  16.         string imagename = Ls_Substrings[EndIndex];
  17.         TupleSplit(imagename, ".png", out Ls_Substrings1);
  18.         string imagename2 = Ls_Substrings1[0]
  19.         
  20.         // 找到原图像的所在路径
  21.         TupleAdd(Image, "/", out d_Sum);
  22.         TupleAdd(d_Sum, imagename2, out d_Sum);
  23.         TupleAdd(d_Sum, ".jpg", out d_Sum);
  24.         DispText(d_Sum);
  25.         
  26. //        DispText(imagepath);
  27.         ReadImage(out M_Image, imagepath);
  28.         ShowImage(M_Image);
  29.         Threshold(M_Image, out M_Region, 0, 10);
  30.         RegionFeatures(M_Region, "area", out d_Value); // area|width|height|row|column|contlength
  31.         if(d_Value>0)
  32.         {
  33.             SmallestRectangle1(M_Region, out i_Row1, out i_Column1, out i_Row2, out i_Column2);
  34.             int i_Width = i_Column2-i_Column1+1;
  35.             int i_Height = i_Row2-i_Row1+1;
  36.             
  37.             ReadImage(out M_Image1, d_Sum);
  38.             imshow(M_Image1);
  39.             CropPart(M_Image1, out M_ImagePart, i_Row1, i_Column1, i_Width, i_Height);
  40.             imshow(M_ImagePart);
  41.             
  42.             // 构建新的保存路径
  43.             TupleAdd(savepath, "/", out newPath);
  44.             TupleAdd(newPath, imagename2, out newPath);
  45.             TupleAdd(newPath, ".png", out newPath);
  46.             DispText(newPath);
  47.             WriteImage(M_ImagePart, "png", -1, newPath);
  48.         }
  49.     }
  50. }
复制代码







回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Opencv|MATLAB|Python|WiTiAi ( 蜀ICP备2021019707号 )

GMT+8, 2025-10-13 18:03 , Processed in 0.156192 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表