码迷,mamicode.com
首页 > 移动开发 > 详细

Android Kotlin opencv MatOfPoint 转 MatOfPoint2f 报错踩坑 (解决)

时间:2020-05-30 10:53:02      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:入参   div   enc   ble   org   ide   解决   efi   测试   

val contours:MutableList<MatOfPoint> = ArrayList()
val contours2f:MutableList<MatOfPoint2f> = ArrayList()

for (point in contours){
    contours2f.add(MatOfPoint2f(point.toArray()))
}

// 无法通过编译, 传入参数类型不匹配

查看 opencv 中 MatOfPoint2f 的构造函数

<init>(vararg Point!) defined in org.opencv.core.MatOfPoint2f
<init>(Long) defined in org.opencv.core.MatOfPoint2f
<init>(Mat!) defined in org.opencv.core.MatOfPoint2f

 

发现(Point...a)被转为了(vararg Point!)

 

经过查资料后改为

val contours:MutableList<MatOfPoint> = ArrayList()
val contours2f:MutableList<MatOfPoint2f> = ArrayList()

for (point in contours){
    contours2f.add(MatOfPoint2f(*point.toArray()))  // 这里多了个*
}

 

IDE不再报错, 手上没有设备, 未测试.

Android Kotlin opencv MatOfPoint 转 MatOfPoint2f 报错踩坑 (解决)

标签:入参   div   enc   ble   org   ide   解决   efi   测试   

原文地址:https://www.cnblogs.com/HoD7/p/12991114.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!