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

  • SEARCH
  • Home
  • 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 9195627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:40:10+00:00 2026-06-17T21:40:10+00:00

I’d like to take the perspective transform matrix returned from OpenCV’s findHomography function and

  • 0

I’d like to take the perspective transform matrix returned from OpenCV’s findHomography function and convert it (either in C++ or Objective-C) to iOS’ CATransform3D. I’d like them to be as close as possible in terms of accurately reproducing the “warp” effect on the Core Graphics side. Example code would really be appreciated!

From iOS’ CATransform3D.h:

/* Homogeneous three-dimensional transforms. */

struct CATransform3D
{
    CGFloat m11, m12, m13, m14;
    CGFloat m21, m22, m23, m24;
    CGFloat m31, m32, m33, m34;
    CGFloat m41, m42, m43, m44;
};

Similar questions:

Apply homography matrix using Core Graphics

convert an opencv affine matrix to CGAffineTransform

  • 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-06-17T21:40:11+00:00Added an answer on June 17, 2026 at 9:40 pm

    Disclaimer

    I have never tried this so take it with a grain of salt.

    CATRansform3D is a 4×4 matrix which operates on a 3 dimensional homogeneous vector (4×1) to produce another vector of the same type. I am assuming that when rendered, objects described by a 4×1 vector have each element divided by the 4th element and the 3rd element is used only to determine which objects appear on top of which. Assuming this is correct…

    Reasoning

    The 3×3 matrix returned by findHomography operates on a 2 dimensional homogeneous vector. That process can be thought of in 4 steps

    1. The first column of the homography is multiplied by x
    2. The second column of the homography is multiplied by y
    3. The third column of the homography is multiplied by 1
    4. the resulting 1st and 2nd vector elements are divided by the 3rd

    You need this process to be replicated in a 4×4 vector in which I am assuming the 3rd element in the resulting vector is meaningless for your purposes.

    Solution

    Construct your matrix like this (H is your homography matrix)

    [H(0,0), H(0,1), 0, H(0,2),
     H(1,0), H(1,1), 0, H(1,2),
          0,      0, 1,      0
     H(2,0), H(2,1), 0, H(2,2)]
    

    This clearly satisfies 1,2 and 3. 4 is satisfied because the homogeneous element is always the last one. That is why the “homogeneous row” if you will had to get bumped down one line. The 1 on the 3rd row is to let the z component of the vector pass through unmolested.

    All of the above is done in row major notation (like openCV) to try to keep things from being confusing. You can look at Tommy’s answer to see how the conversion to column major looks (you basically just transpose it). Note however that at the moment Tommy and I disagree about how to construct the matrix.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I need a function that will clean a strings' special characters. I do NOT

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.