zoukankan      html  css  js  c++  java
  • 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()))  // 这里多了个*
    }

    成功通过编译.


    2020年05月30日

  • 相关阅读:
    ubuntu安装netcat
    护网工作
    ssrf绕过
    文件包含绕过
    thinkphp5.0.23
    xxe
    文件上传
    文件上传html xss
    获取网站title
    RobotFramework使用AutoItLibrary输入字符错误问题
  • 原文地址:https://www.cnblogs.com/HoD7/p/12991114.html
Copyright © 2011-2022 走看看