C#emgu.cv.matrix< float>到int [英] C# emgu.cv.matrix<float> to int

查看:104
本文介绍了C#emgu.cv.matrix< float>到int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助我使用Emgu.Cv.Matrix< float> to int当我运行代码而不转换;



参数1:无法从'Emgu.CV.Matrix'转换为'int'



当我尝试 Convert.ToInt32(rsmmatrixtanimlayici)



参数2:mscorlib.dll中发生未处理的System.InvalidCastException类型异常< br /> 
< br />
附加信息:'Emgu.CV.Matrix`1 [System.Single]'türündekinesne'System.IConvertible'türüneatılamadı。





 eslestirici =  new  BruteForceMatcher< Single>(DistanceType.L2); 
eslestirici.Add(aranacakrsmmatrixtanimlayici);
matrixtanimlayiciindeksleri = new Matrix< int>(rsmmatrixtanimlayici.Rows,enyakinkomsu);
matrixuzaklik = new Matrix< Single>(Convert.ToInt32(rsmmatrixtanimlayici),enyakinkomsu);
eslestirici.KnnMatch(rsmmatrixtanimlayici,matrixtanimlayiciindeksleri,matrixuzaklik,enyakinkomsu, null );





[ ScreenShot1 ]



matrixuzaklik is Single matrixuzaklik = new Matrix< single>(rsmmatrixtanimlayici,enyakinkomsu);



[ ScreenShot2 ]



我有什么试过:



i试图转换.ToInt32(rsmmatrixtanimlayici)它不起作用。

解决方案

< blockquote>矩阵是Emgu CV库中的二维实体,而您试图将其转换为单个实体对象。这就是问题#1。其次,在 Convert.ToType()函数下使用的任何对象都必须实现 IConvertible 接口(因此,错误那是向你展示的)。



有两种方法可以做到这一点,首先是从Matrix本身访问数据,

  int   value  = rsmmatrixtanimlayici [ 0 ];  //  类型是int,还是single还是float? 



其次,你可能想要使用任何可以为你做的技巧的内置帮助器,即使这样你也需要使用整数数组( int [] not int )以适应该矩阵中的数据。



然后,再次,这一切都取决于矩阵的深度,它也可以是三维的,例如彩色图像。



IConvertible Interface(System) [ ^ ]

c# - 在emgu cv中使用矩阵 - 堆栈溢出 [ ^ ]


 matrixuzaklik =  new  Matrix< single>(rsmmatrixtanimlayici.Rows,enyakinkomsu); 


Anyone can help me with Emgu.Cv.Matrix<float> to int When i run the codes without converting;

Argument 1: cannot convert from 'Emgu.CV.Matrix' to 'int'

When i try to Convert.ToInt32(rsmmatrixtanimlayici)

Argument 2: An unhandled exception of type 'System.InvalidCastException' occurred in mscorlib.dll<br />
<br />
Additional information: 'Emgu.CV.Matrix`1[System.Single]' türündeki nesne 'System.IConvertible' türüne atılamadı.



eslestirici = new BruteForceMatcher<Single>(DistanceType.L2);
           eslestirici.Add(aranacakrsmmatrixtanimlayici);
           matrixtanimlayiciindeksleri = new Matrix<int>(rsmmatrixtanimlayici.Rows, enyakinkomsu);
           matrixuzaklik = new Matrix<Single>(Convert.ToInt32(rsmmatrixtanimlayici), enyakinkomsu);
           eslestirici.KnnMatch(rsmmatrixtanimlayici, matrixtanimlayiciindeksleri, matrixuzaklik, enyakinkomsu, null);



[ScreenShot1]

matrixuzaklik is Single matrixuzaklik = new Matrix<single>(rsmmatrixtanimlayici, enyakinkomsu);

[ScreenShot2]

What I have tried:

i have tried to Convert.ToInt32(rsmmatrixtanimlayici) it's not working.

解决方案

A matrix is a two dimensional entity in the Emgu CV library whereas you are trying to cast it to a single entity object. That is the problem #1. Secondly, any object that is used under Convert.ToType() function must implement the IConvertible interface (thus, the error that was shown to you).

There are two ways that you can do this, first of all being accessing the data from the Matrix itself,

int value = rsmmatrixtanimlayici[0]; // Is the type int, or single, or float?


Secondly, you may want to use any built-in helper that can do the trick for you, even then you would require to use an integer array (int[] not int) to accommodate for the data in that matrix.

Then again, that all depends on the depth of the Matrix it can be 3-dimensional too, in the case of a color image for instance.

IConvertible Interface (System)[^]
c# - Work with matrix in emgu cv - Stack Overflow[^]


matrixuzaklik = new Matrix<single>(rsmmatrixtanimlayici.Rows, enyakinkomsu);


这篇关于C#emgu.cv.matrix&lt; float&gt;到int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆