Convert Vec4i to Java

asked 2013-10-28 06:43:40 -0600

ssdehero gravatar image

updated 2016-05-21 14:22:10 -0600

Hi I'm new to OpenCV in Android. I'm trying to covert a C++ code into Java. I've been stucked in some point that I cannot continue.

std::vector<cv::Vec4i> lines;
cv::HoughLinesP(bw, lines, 1, CV_PI/180, 70, 30, 10);

// Expand the lines
for (int i = 0; i < lines.size(); i++)
{
    cv::Vec4i v = lines[i];
    lines[i][0] = 0;
    lines[i][1] = ((float)v[1] - v[3]) / (v[0] - v[2]) * -v[0] + v[1]; 
    lines[i][2] = src.cols; 
    lines[i][3] = ((float)v[1] - v[3]) / (v[0] - v[2]) * (src.cols - v[2]) + v[3];
}

half way I converted.. upto the TODO

    MatOfInt4 lines= new MatOfInt4();
    Imgproc.HoughLinesP(bw, lines, 1, Math.PI/180, 70, 30, 10);

    int[] lineArray = lines.toArray();
    // Expand the lines
    //TODO 
    for (int i = 0; i < lineArray.length; i++)
    {
        int v = lineArray[i];
        lines.[i][0] = 0;
        lines[i][1] = ((float)v[1] - v[3]) / (v[0] - v[2]) * -v[0] + v[1]; 
        lines[i][2] = src.cols(); 
        lines[i][3] = ((float)v[1] - v[3]) / (v[0] - v[2]) * (src.cols() - v[2]) + v[3];
    }

which I'm confused is inside the for loop. when converted lines in to a Array it gives a int array. But inside the for loop again v is defined which should be a array. I didn't get this point. Can anybody please help me to get through this. Thank you in advance.

edit retag flag offensive close merge delete