← Back

ofxHomography

github.com/paulobarcelos/ofxHomography · @paulobarcelos
OF 0.12 Releases Graphics

openFrameworks addon for computing homography matrices for perspective warps, projection mapping, and screen-coordinate transforms.

19 9 Last commit 4mo ago Created 13y ago

Branches ahead of master

These branches have commits not yet on master — could be unmerged fixes or work in progress worth a look.

develop 1 commit ahead · last commit 5y ago

README

ofxHomography



ofxHomography

ofxHomography is a small openFrameworks addon for finding the homography matrix between two sets of four points. It is useful for perspective warps, projection mapping helpers, screen-to-surface coordinate transforms, and other quad-to-quad mapping tasks.

The addon is header-only and has no external dependencies beyond openFrameworks' bundled math/GLM support.

Installation



Clone or copy this repository into your openFrameworks addons/ folder:

cd /path/to/openFrameworks/addons
git clone https://github.com/paulobarcelos/ofxHomography.git


Add ofxHomography to your project's addons.make, or include it through the openFrameworks Project Generator.

The example also includes an of.yml recipe for ofWorks/ofGen users.

Quick Start



#include "ofxHomography.h"

std::array<glm::vec2, 4> source = {{
	{ 0.0f, 0.0f },
	{ 100.0f, 0.0f },
	{ 100.0f, 100.0f },
	{ 0.0f, 100.0f }
}};

std::array<glm::vec2, 4> destination = {{
	{ 20.0f, 30.0f },
	{ 420.0f, 10.0f },
	{ 390.0f, 360.0f },
	{ 30.0f, 410.0f }
}};

glm::mat4 homography = ofxHomography::findHomography(source, destination);

ofPushMatrix();
ofMultMatrix(homography);
ofDrawRectangle(0, 0, 100, 100);
ofPopMatrix();

glm::vec2 localPoint(80, 80);
glm::vec2 screenPoint = ofxHomography::toScreenCoordinates(localPoint, homography);


API



For official openFrameworks builds that still expose the legacy math classes, toScreenCoordinates(const ofPoint&, const ofMatrix4x4&) is also available for compatibility.

Compatibility



Current master is tested with:

Version 1.1.0 remains the last tagged release documented as tested with openFrameworks 0.11.2.

Development



Official openFrameworks:

cd /path/to/openFrameworks/addons/ofxHomography/example
make Debug -j8
make RunDebug


ofWorks/ofGen:

cd /path/to/ofworks/addons/ofxHomography/example
/path/to/ofworks/ofGen/dist/ofgen build


License



MIT

Version History



Version 2.0.0



Version 1.1.0 (2021.03.31)



Get this addon

HTTPS
SSH

Latest release

2.0.0 ofxHomography 2.0.0 published 4mo ago

What's Changed



  • Modernizes the addon around current openFrameworks math conventions: primary APIs now return/use glm::mat4 and glm::vec2 / glm::vec3.
  • Updates the example from the legacy testApp naming to ofApp.
  • Adds an of.yml recipe for ofWorks/ofGen while keeping the official openFrameworks Makefile files.
  • Improves the README with installation, quick-start, API, compatibility, and development notes.
  • Keeps a legacy toScreenCoordinates(const ofPoint&, const ofMatrix4x4&) overload for official openFrameworks builds that expose the old math classes.

Compatibility



Verified on macOS with:

  • openFrameworks 0.12.1 using make Debug -j8 in the example.
  • ofWorks/ofGen 1.0.8 using ofgen build with the included of.yml.

Upgrade Note



This is a major release because the primary convenience API now returns glm::mat4 instead of ofMatrix4x4. Code that uses ofMultMatrix should continue to work in current openFrameworks, but projects storing the return value as ofMatrix4x4 may need to switch to glm::mat4 or rely on openFrameworks' conversion support.