Convert Vec4i to Java openCV

后端 未结 1 448
傲寒
傲寒 2020-12-19 13:39

I\'m new to OpenCV in Android. I\'m trying to covert a C++ code into Java. I am stuck in some point that I cannot continue.

std::vector line         


        
相关标签:
1条回答
  • 2020-12-19 13:55

    Finally I managed to write the working code. with help of this link

        Mat lines = new Mat();
        int threshold = 70;
        int minLineSize = 30;
        int lineGap = 10;
    
        Imgproc.HoughLinesP(thresholdImage, lines, 1, Math.PI / 180, threshold,
                minLineSize, lineGap);
    
        for (int x = 0; x < lines.cols(); x++) {
    
            double[] vec = lines.get(0, x);
            double[] val = new double[4];
    
            val[0] = 0;
            val[1] = ((float) vec[1] - vec[3]) / (vec[0] - vec[2]) * -vec[0] + vec[1];
            val[2] = src.cols();
            val[3] = ((float) vec[1] - vec[3]) / (vec[0] - vec[2]) * (src.cols() - vec[2]) + vec[3];
    
            lines.put(0, x, val);
    
        }
    
    0 讨论(0)
提交回复
热议问题