Android Kotlin opencv MatOfPoint 转 MatOfPoint2f 报错踩坑 (解决)
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不再报错, 手上没有设备, 未测试.
相关推荐
xiaouncle 2020-07-31
源码物语 2020-07-18
XGQ 2020-06-21
fengyun 2020-06-14
OldBowl 2020-06-11
zagnix 2020-06-04
xhao 2020-06-04
付春杰Blog 2020-05-31
shenxiuwen 2020-05-29
XGQ 2020-05-26
zhuyonge 2020-05-09
zcpHappy 2020-04-30
luohui 2020-04-29
fraternityjava 2020-04-29
willluckysmile 2020-04-24
shayuchaor 2020-04-20
fengyun 2020-04-17
少年阿涛 2020-04-11