Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

What are the correct data types for contours and moments?

I have a running program for the Lego in C++ Now, I find out that LeJos for the Mindstorm EV3 only has an engine for Java for Eclipse. So, I need to convert my running C++ program to Java in Eclipse to have a link to the EV3. But, I am lost in the data structures. List, Array, Array-of-List, Mat, Array-of-Mat, Mat-of-Point, whatever... I have converted most of the code, but am stuck on the following...

Someone must know how to do this. THANK YOU

//                  vector<Moments> mu(  contours.size()  );                                 //  C++
              List<MatOfPoint> contours = new ArrayList<MatOfPoint>(); 
        ArrayList mu = new ArrayList<contours.size()>  ();
                Imgproc.cvtColor(dst, dst, Imgproc.COLOR_BGR2GRAY);
        Imgproc.threshold(dst, dst, 0, 255, Imgproc.THRESH_BINARY_INV | Imgproc.THRESH_OTSU);
        Imgproc.findContours(
            dst,                                                                    //  Image                                                   
            contours,                                                         //  Contours                                             
            hierarchy,                                                       //  Hierarchy                                              
            Imgproc.RETR_TREE,                                  //  int - Contour retrieval mode: RETR_LIST, RETR_CCOMP         
            Imgproc.CHAIN_APPROX_NONE);        //  int - Contour approximantion Method: CHAIN_APPROX_SIMPLE, CHAIN_APPROX_NONE
        HighGui.imshow("After findContours.   Press any key ...", dst);
        HighGui.waitKey();
int SumOfMoments = 0;
        int Mass = 0;

        for (int i = 0; i < contours.size(); i++)                                                  //  From C++
        {                                                                                                                     //  From C++
            mu[i] = moments(contours[i], false);                           //  From C++
            SumOfMoments += mu[i].m10;                                      //  From C++
            Mass += mu[i].m00;                                                            //  From  C++
        }

What are the correct data types for contours and moments?

I have a running program for the Lego in C++ Now, I find out that LeJos for the Mindstorm EV3 only has an engine for Java for Eclipse. So, I need to convert my running C++ program to Java in Eclipse to have a link to the EV3. But, I am lost in the data structures. List, Array, Array-of-List, Mat, Array-of-Mat, Mat-of-Point, whatever... I have converted most of the code, but am stuck on the following...

Someone must know how to do this. THANK YOU

//               //             vector<Moments> mu(  contours.size()  );                 //  C++
              List<MatOfPoint> contours = new ArrayList<MatOfPoint>(); 
        ArrayList mu = new ArrayList<contours.size()>  ();
             Imgproc.cvtColor(dst, dst, Imgproc.COLOR_BGR2GRAY);
        Imgproc.threshold(dst, dst, 0, 255, Imgproc.THRESH_BINARY_INV | Imgproc.THRESH_OTSU);
        Imgproc.findContours(
            dst,                                             //  Image                                                   
            contours,                                    //  Contours                                             
            hierarchy,                                   //  Hierarchy                                              
            Imgproc.RETR_TREE,                   //  int - Contour retrieval mode: RETR_LIST, RETR_CCOMP         
            Imgproc.CHAIN_APPROX_NONE);        //  int - Contour approximantion Method: CHAIN_APPROX_SIMPLE, CHAIN_APPROX_NONE
        HighGui.imshow("After findContours.   Press any key ...", dst);
        HighGui.waitKey();
 int SumOfMoments = 0;
        int Mass = 0;

        for (int i = 0; i < contours.size(); i++)                               //  From C++
        {                                                                                    //  From C++
            mu[i] = moments(contours[i], false);                      //  From C++
            SumOfMoments += mu[i].m10;                               //  From C++
            Mass += mu[i].m00;                                               //  From  C++
        }

What are the correct data types for contours and moments?

I have a running program for the Lego in C++ Now, I find out that LeJos for the Mindstorm EV3 only has an engine for Java for Eclipse. So, I need to convert my running C++ program to Java in Eclipse to have a link to the EV3. But, I am lost in the data structures. List, Array, Array-of-List, Mat, Array-of-Mat, Mat-of-Point, whatever... I have converted most of the code, but am stuck on the following...

Someone must know how to do this. THANK YOU

         //             vector<Moments> mu(  contours.size()  );                //  C++
             List<MatOfPoint> contours = new ArrayList<MatOfPoint>(); 
         ArrayList mu = new ArrayList<contours.size()>  ();
            Imgproc.cvtColor(dst, dst, Imgproc.COLOR_BGR2GRAY);
         Imgproc.threshold(dst, dst, 0, 255, Imgproc.THRESH_BINARY_INV | Imgproc.THRESH_OTSU);
        Imgproc.findContours(
            dst,                                            //  Image                                                   
            contours,                                   //  Contours                                             
            hierarchy,                                  //  Hierarchy                                              
            Imgproc.RETR_TREE,                  //  int - Contour retrieval mode: RETR_LIST, RETR_CCOMP         
            Imgproc.CHAIN_APPROX_NONE);        //  int - Contour approximantion Method: CHAIN_APPROX_SIMPLE, CHAIN_APPROX_NONE
        HighGui.imshow("After findContours.   Press any key ...", dst);
        HighGui.waitKey();
        int SumOfMoments = 0;
        int Mass = 0;

        for (int i = 0; i < contours.size(); i++)                              //  From C++
        {                                                                  //  From C++
            mu[i] = moments(contours[i], false);                     //  From C++
            SumOfMoments += mu[i].m10;                              //  From C++
            Mass += mu[i].m00;                                              //  From  C++
        }

What are the correct data types for contours and moments?

I have a running program for the Lego in C++ Now, I find out that LeJos for the Mindstorm EV3 only has an engine for Java for Eclipse. So, I need to convert my running C++ program to Java in Eclipse to have a link to the EV3. But, I am lost in the data structures. List, Array, Array-of-List, Mat, Array-of-Mat, Mat-of-Point, whatever... I have converted most of the code, but am stuck on the following...

Someone must know how to do this. THANK YOU

         //             vector<Moments> mu(  contours.size()  );                //  C++
            List<MatOfPoint> contours = new ArrayList<MatOfPoint>(); 
            ArrayList mu = new ArrayList<contours.size()>  ();
            Imgproc.cvtColor(dst, dst, Imgproc.COLOR_BGR2GRAY);
            Imgproc.threshold(dst, dst, 0, 255, Imgproc.THRESH_BINARY_INV | Imgproc.THRESH_OTSU);
        Imgproc.findContours(
            dst,                  //  Image               
            contours,             //  Contours       
            hierarchy,            //  Hierarchy                     
            Imgproc.RETR_TREE,    //  int - Contour retrieval mode: RETR_LIST, RETR_CCOMP         
            Imgproc.CHAIN_APPROX_NONE);    //  int - Contour approximantion Method: CHAIN_APPROX_SIMPLE, -ContourapproximantionMethod:CHAIN_APPROX_SIMPLE, CHAIN_APPROX_NONE
        HighGui.imshow("After findContours.   Press any key ...", dst);
        HighGui.waitKey();
        int SumOfMoments = 0;
        int Mass = 0;

        for (int i = 0; i < contours.size(); i++)        //  From C++
        {                                               //  From C++
            mu[i] = moments(contours[i], false);        //  From C++
            SumOfMoments += mu[i].m10;                  //  From C++
            Mass += mu[i].m00;                           //  From  C++
        }

What are the correct data types for contours and moments?

I have a running program for the Lego in C++ Now, I find out that LeJos for the Mindstorm EV3 only has an engine for Java for Eclipse. So, I need to convert my running C++ program to Java in Eclipse to have a link to the EV3. But, I am lost in the data structures. List, Array, Array-of-List, Mat, Array-of-Mat, Mat-of-Point, whatever... I have converted most of the code, but am stuck on the following...

Someone must know how to do this. THANK YOU

        //  //            vector<Moments> mu(  contours.size()  );                //  C++
    List<MatOfPoint> contours = new ArrayList<MatOfPoint>(); 
    ArrayList mu = new ArrayList<contours.size()>  ();
    Imgproc.cvtColor(dst, dst, Imgproc.COLOR_BGR2GRAY);
    Imgproc.threshold(dst, dst, 0, 255, Imgproc.THRESH_BINARY_INV | Imgproc.THRESH_OTSU);
    Imgproc.findContours(
            dst,                 //  Image              
            contours,            //  Contours      
            hierarchy,           //  Hierarchy                    
            Imgproc.RETR_TREE,   //  int - Contour retrieval mode: RETR_LIST, RETR_CCOMP         
RETR_CCOMP
            Imgproc.CHAIN_APPROX_NONE);   //  int -ContourapproximantionMethod:CHAIN_APPROX_SIMPLE, CHAIN_APPROX_NONE
        HighGui.imshow("After findContours.   Press any key ...", dst);
        HighGui.waitKey();
        int SumOfMoments = 0;
        int Mass = 0;

        for (int i = 0; i < contours.size(); i++)       //  From C++
        {                                              //  From C++
            mu[i] = moments(contours[i], false);       //  From C++
            SumOfMoments += mu[i].m10;                 //  From C++
            Mass += mu[i].m00;                          //  From  C++
        }

What are the correct data types for contours and moments?

I have a running program for the Lego in C++ Now, I find out that LeJos for the Mindstorm EV3 only has an engine for Java for Eclipse. So, I need to convert my running C++ program to Java in Eclipse to have a link to the EV3. But, I am lost in the data structures. List, Array, Array-of-List, Mat, Array-of-Mat, Mat-of-Point, whatever... I have converted most of the code, but am stuck on the following...

Someone must know how to do this. THANK YOU

  //            vector<Moments> mu(  contours.size()  );                //  C++
   List<MatOfPoint> contours = new ArrayList<MatOfPoint>(); 
   ArrayList mu = new ArrayList<contours.size()>  ();
   Imgproc.cvtColor(dst, dst, Imgproc.COLOR_BGR2GRAY);
   Imgproc.threshold(dst, dst, 0, 255, Imgproc.THRESH_BINARY_INV | Imgproc.THRESH_OTSU);
   Imgproc.findContours(
            dst,                 //  Image              
            contours,            //  Contours      
            hierarchy,           //  Hierarchy                    
            Imgproc.RETR_TREE,   //  int - Contour retrieval mode: RETR_LIST, RETR_CCOMP
            Imgproc.CHAIN_APPROX_NONE);   //  int -ContourapproximantionMethod:CHAIN_APPROX_SIMPLE, CHAIN_APPROX_NONE
     HighGui.imshow("After findContours.   Press any key ...", dst);
     HighGui.waitKey();
     int SumOfMoments = 0;
     int Mass = 0;

     for (int i = 0; i < contours.size(); i++)       //  From C++
     {                                              //  From C++
         mu[i] = moments(contours[i], false);       //  From C++
         SumOfMoments += mu[i].m10;                 //  From C++
         Mass += mu[i].m00;                          //  From  C++
     }

What are the correct data types for contours and moments?

I have a running program for the Lego in C++ Now, I find out that LeJos for the Mindstorm EV3 only has an engine for Java for Eclipse. So, I need to convert my running C++ program to Java in Eclipse to have a link to the EV3. But, I am lost in the data structures. List, Array, Array-of-List, Mat, Array-of-Mat, Mat-of-Point, whatever... I have converted most of the code, but am stuck on the following...

Someone must know how to do this. THANK YOU

  //            vector<Moments> mu(  contours.size()  );                //  C++
   List<MatOfPoint> contours = new ArrayList<MatOfPoint>(); 
   ArrayList mu = new ArrayList<contours.size()>  ();
   Imgproc.cvtColor(dst, dst, Imgproc.COLOR_BGR2GRAY);
   Imgproc.threshold(dst, dst, 0, 255, Imgproc.THRESH_BINARY_INV | Imgproc.THRESH_OTSU);
   Imgproc.findContours(
      dst,                  //  Image              
      contours,             //  Contours      
      hierarchy,            //  Hierarchy                    
      Imgproc.RETR_TREE,   //  int   //int - Contour retrieval mode: RETR_LIST, RETR_CCOMP
            Imgproc.CHAIN_APPROX_NONE);   //  int Imgproc.CHAIN_APPROX_NONE);//int -ContourapproximantionMethod:CHAIN_APPROX_SIMPLE, CHAIN_APPROX_NONE
    HighGui.imshow("After findContours.   Press any key ...", dst);
    HighGui.waitKey();
    int SumOfMoments = 0;
    int Mass = 0;

    for (int i = 0; i < contours.size(); i++)       //  From C++
    {                                              //  From C++
        mu[i] = moments(contours[i], false);       //  From C++
        SumOfMoments += mu[i].m10;                 //  From C++
        Mass += mu[i].m00;                          //  From  C++
    }

What are the correct data types for contours and moments?

I have a running program for the Lego in C++ C++. Now, I find out that LeJos for the Mindstorm EV3 only has an engine for Java for Eclipse. So, I need to convert my running C++ program to Java in Eclipse to have a link to the EV3. But, I am lost in the data structures. List, Array, Array-of-List, Mat, Array-of-Mat, Mat-of-Point, whatever... I have converted most of the code, but am stuck on the following...

Someone must know how to do this. THANK YOU

  //            vector<Moments> mu(  contours.size()  );                //  C++
   List<MatOfPoint> contours = new ArrayList<MatOfPoint>(); 
   ArrayList mu = new ArrayList<contours.size()>  ();
   Imgproc.cvtColor(dst, dst, Imgproc.COLOR_BGR2GRAY);
   Imgproc.threshold(dst, dst, 0, 255, Imgproc.THRESH_BINARY_INV | Imgproc.THRESH_OTSU);
   Imgproc.findContours(
     dst,                          //  Image              
     contours,                     //  Contours      
     hierarchy,                    //  Hierarchy                    
     Imgproc.RETR_TREE,     //int - Contour retrieval mode: RETR_LIST, RETR_CCOMP
     Imgproc.CHAIN_APPROX_NONE);//int -ContourapproximantionMethod:CHAIN_APPROX_SIMPLE, CHAIN_APPROX_NONE
    HighGui.imshow("After findContours.   Press any key ...", dst);
    HighGui.waitKey();
    int SumOfMoments = 0;
    int Mass = 0;

    for (int i = 0; i < contours.size(); i++)      //  From C++
    {                                              //  From C++
        mu[i] = moments(contours[i], false);       //  From C++
        SumOfMoments += mu[i].m10;                 //  From C++
        Mass += mu[i].m00;                         //  From  C++
    }