C# 基础学习之 :ArrayList 取值

由于ArrayList是泛型,其类型不确定,所以无法直接读取其中的元素数据, 应该先将ArrayList数据值进行强制转换然后再读取。例如使用库读取二维码,由于使用的是库,ArrayList类型不确定

需要进行强制转换:

 

static void Main (string[] args) 
       {
            Mat src = new Mat (@"E:\Apriltags\TAG36H11\tag36h11_0.png", ImreadModes.Color);
            Apriltag ap = new Apriltag ("canny", true, "tag36h11");
            var result = ap.detect (src);
            TagDetection[] newDate = new TagDetection[result.Count];
            for (int i = 0; i < result.Count; i++)
            {
                newDate[i] = (TagDetection) result[i];
                Console.WriteLine("id: " + newDate[i].id);
            }
            Console.ReadKey();
        }

 

posted on 2022-06-10 10:49  kuangxionghui  阅读(1258)  评论(0编辑  收藏  举报