Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7543563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:27:39+00:00 2026-05-30T08:27:39+00:00

Using JavaCV. I have a 2 sets of CvPoint2D32f points in an ArrayList one

  • 0

Using JavaCV. I have a 2 sets of CvPoint2D32f points in an ArrayList one from an image caputer from a mobile phone and another from a known image source that is constant.

I want to apply the cvFindHomogrpahy() Method using these points to find a Homography Matrix between the points. I am using the following code to try and do this but I am stuck on how to get from the points I know to the 2 cvMat that the cvFindHomogrpahy() Method takes as parameters:

matsrc = cvCreateMat(points.size(), 2, CV_32FC1);
matdst = cvCreateMat(known.size(), 2, CV_32FC1);

for(int s=0; s < points.size(); s++){
     CvPoint2D32f p = (CvPoint2D32f)points.get(i).get("Point");
     //Add this point to matsrc                         
}

for(int s=0; s < known.size(); s++){
     CvPoint2D32f p = (CvPoint2D32f)known.get(i).get("Point");
     //Add this point to matdst                         
}


CvMat mat = cvCreateMat(3, 3, CV_32FC1);
cvFindHomography(matsrc, matdst, mat); //Here the matrices created are used to find the 3x3 Homography transform Matrix

Am I going about this the totally wrong way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T08:27:40+00:00Added an answer on May 30, 2026 at 8:27 am

    In short you can use the put method of CvMat.

    Here is a complete solution after some modifications of your code:

    import java.io.*;
    import java.util.*;
    
    import static com.googlecode.javacv.cpp.opencv_core.*;
    import static com.googlecode.javacv.cpp.opencv_imgproc.*;
    import static com.googlecode.javacv.cpp.opencv_highgui.*;
    import static com.googlecode.javacv.cpp.opencv_calib3d.*;
    
    /**
     *
     * @author rics
     */
    public class Main {
    
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {      
        List<CvPoint2D32f> points = new ArrayList<CvPoint2D32f>();
        List<CvPoint2D32f> known = new ArrayList<CvPoint2D32f>();
        // points and known should be filled with valid values
        // here are just some ad-hoc numbers that do not result a singular (unsolvable) configuration 
        for(int i=0; i < 2; i++){
            points.add(cvPoint2D32f((double)i,10 - 2* (double)i));
            known.add(cvPoint2D32f((double)i,10 - 2*(double)i));
        }
        for(int i=2; i < 5; i++){
            points.add(cvPoint2D32f((double)i,(double)i));
            known.add(cvPoint2D32f((double)i,(double)i));
        }
        CvMat matsrc = cvCreateMat(points.size(), 2, CV_32FC1);
        CvMat matdst = cvCreateMat(known.size(), 2, CV_32FC1);
    
        // filling the matrices with the point coordinates
        for(int s=0; s < points.size(); s++){
            CvPoint2D32f p = points.get(s);//.get("Point");
            //Add this point to matsrc                         
            matsrc.put(s,0,p.x());
            matsrc.put(s,1,p.y());
        }
    
        for(int s=0; s < known.size(); s++){
            CvPoint2D32f p = known.get(s);//.get("Point");
            //Add this point to matdst                         
            matdst.put(s,0,p.x());
            matdst.put(s,1,p.y());
        }
    
        CvMat mat = cvCreateMat(3, 3, CV_32FC1);
        cvFindHomography(matsrc, matdst, mat); //Here the matrices created are used to find the 3x3 Homography transform Matrix
        // displaying the resulting matrix
        for( int i = 0; i < 3; ++i) {
            for( int j = 0; j < 3; ++j) {
            System.out.print(mat.get(i,j) + ",");
            }
            System.out.println();
        }
        }
    }
    

    The result for me is:

    1.0,5.011022034363615E-16,-5.249974158069671E-15,
    1.6479031282788333E-15,1.0,-5.495862740459911E-15,
    4.4222287862990617E-16,1.2693993089577568E-16,1.0,
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using online interfaces to a version control system is a nice way to have
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
I have a project where I am responsible for fixing some errors and another
I have my system set up to compile jee6 code from the command line
I have downloaded the source code of Apache Lucene using Subversion. Now I want
I have followed this thread now when i try to build using maven plugin
I have an Ant script that I would like to execute using a button
Two questions in one, but I have a very short test case demonstrating my
I develop a project using .jar to reuse code. So I have on .jar
I'm using JavaCV for a university project. It is essentially a motion detector. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.