将VB程序的特定行转换为C#
嗨,我正在写一个基于VB程序的C程序来识别图像中的文本。然而,我似乎无法计算出这条线的C#等价物:将VB程序的特定行转换为C#,c#,vb.net,comparison,emgucv,contour,C#,Vb.net,Comparison,Emgucv,Contour,嗨,我正在写一个基于VB程序的C程序来识别图像中的文本。然而,我似乎无法计算出这条线的C#等价物: listOfContoursWithData.Sort(Function(oneContourWithData, otherContourWithData) oneContourWithData.boundingRect.X.CompareTo(otherContourWithData.boundingRect.X)) 这是ContoursWithData类,listOfContoursWith
listOfContoursWithData.Sort(Function(oneContourWithData, otherContourWithData) oneContourWithData.boundingRect.X.CompareTo(otherContourWithData.boundingRect.X))
这是ContoursWithData类,listOfContoursWithData是该类的一个实例:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Emgu.CV.Util;
namespace TrainAndTest
{
public class ContourWithData
{
const int MIN_CONTOUR_AREA = 100;
public VectorOfPoint contour; // contour
public System.Drawing.Rectangle boundingRect; // bounding rect for contour
public double dblArea; // area of contour
public bool checkIfContourIsValid(){
if ((dblArea < MIN_CONTOUR_AREA))
return false;
else
return true;
}
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用System.Threading.Tasks;
使用Emgu.CV.Util;
名称空间训练与测试
{
使用数据的公共类
{
const int MIN_等高线面积=100;
点等高线的公共向量;//等高线
public System.Drawing.Rectangle boundingRect;//轮廓的边界rect
公共双dblArea;//等高线面积
公共bool checkIfContourIsValid(){
if((dblArea<最小轮廓面积))
返回false;
其他的
返回true;
}
}
您可以使用lambda表达式:
listOfContoursWithData.Sort((oneContourWithData, otherContourWithData) =>
oneContourWithData.boundingRect.X.CompareTo(otherContourWithData.boundingRect.X));
List.Sort()
方法将比较作为参数。这是一个将两个ContourWithData
实例作为输入的委托,并返回一个int您可以使用lambda表达式:
listOfContoursWithData.Sort((oneContourWithData, otherContourWithData) =>
oneContourWithData.boundingRect.X.CompareTo(otherContourWithData.boundingRect.X));
List.Sort()
方法将一个比较
作为参数。这是一个代理,它将两个ContourWithData
实例作为输入,并返回一个int
isListofContourWithData
列表
列表
?谢谢,这对我帮助很大:)谢谢,这帮助很大我非常生气:)