Giter Site home page Giter Site logo

paulhoux / cinder-warping Goto Github PK

View Code? Open in Web Editor NEW
66.0 10.0 31.0 1.44 MB

A Cinder block that enables you to easily create editable bi-linear and perspective warps, or a combination of the two.

License: GNU General Public License v3.0

C++ 99.86% C 0.14%

cinder-warping's Introduction

Donate

Cinder-Warping

A Cinder block that enables you to easily create editable bi-linear and perspective warps, or a combination of the two.

Preview

Image warping, as used in this block, is the process of manipulating an image so that it can be projected onto flat or curved surfaces without distortion. There are three types of warps available:

  • Perspective warp: performs image correction for projecting onto flat surfaces in case the projector is not horizontally and/or vertically aligned with the wall. Use it to exactly project your content on a rectangular area on a wall or building, regardless of how your projector is setup. For best results, disable any keystone correction on the projector. Then simply drag the four corners of your content where you want them to be on the wall.
  • Bilinear warp: inferior to perspective warping on flat surfaces, but allows projecting onto curved surfaces. Simply add control points to the warp and drag them to where you want your content to be.
  • Perspective-bilinear warp: a combination of both techniques, where you first drag the four corners of your content to the desired location on the wall, then adjust for curvatures using the additional control points. If you (accidentally) move your projector later, all you need to do is adjust the four corners and the projection should perfectly fit on the curved wall again.
Adding this block to Cinder

This block is meant to be used with version 0.9.0 (or higher) of Cinder.

To add this block to your copy of Cinder, so it will be detected automatically by TinderBox:

  • Open a command window (or Terminal)
  • Switch to the disk containing the Cinder root folder, e.g.: d:
  • Browse to the Cinder root folder: cd path\to\cinder_master
  • Add the Warping block to the blocks folder: git clone https://github.com/paulhoux/Cinder-Warping.git blocks/Cinder-Warping

Alternatively, you can download the repository as a ZIP-file and manually add the files to a "cinder_master\blocks\Cinder-Warping" folder.

Creating a sample application using Tinderbox

The provided sample will show you how to create warps, read them from and write them to a settings file, toggle the editor and handle mouse and key events. To create and compile the sample:

  • Run Cinder's TinderBox
  • Select "Warping: Basic" from the Template popup menu
  • Choose a name for the project
  • Choose a location for the project
  • Choose your environment(s) of choice
  • Press "Next"
  • Make sure the "Warping" block is enabled (Install: Copy or Relative)
  • Press "Finish"
Controls

The block provides a built-in editor to adjust your warps. When activated using the Warp::enableEditMode(true) function, these are the keys you can use:

  • Use mouse or cursor keys to move the currently selected control point
  • Press - or + to change brightness
  • Press R to reset the warp to its default settings
  • Press F1 to reduce the number of horizontal control points
  • Press F2 to increase the number of horizontal control points
  • Press F3 to reduce the number of vertical control points
  • Press F4 to increase the number of vertical control points
  • Press F5 to decrease the mesh resolution
  • Press F6 to increase the mesh resolution
  • Press F7 to toggle adaptive mesh resolution
  • Press TAB to select the next control point
  • Press M to toggle between linear and curved mapping (unavailable for Perspective warps)
  • Press F9 to rotate content counter-clockwise (unavailable for non-Perspective warps)
  • Press F10 to rotate content clockwise (unavailable for non-Perspective warps)
  • Press F11 to flip content horizontally (unavailable for non-Perspective warps)
  • Press F12 to flip content vertically (unavailable for non-Perspective warps)
To-Do's
  • Support for call-backs or lambda's when iterating over all warps
  • Out-of-the-box support for multiple windows
  • Support for other warp types, e.g. WarpSpherical
Copyright notice

Copyright (c) 2010-2017, Paul Houx - All rights reserved. This code is intended for use with the Cinder C++ library: http://libcinder.org

Cinder-Warping is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Cinder-Warping is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Cinder-Warping. If not, see http://www.gnu.org/licenses/.

cinder-warping's People

Contributors

bgbotond avatar gaborpapp avatar heisters avatar num3ric avatar paulhoux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cinder-warping's Issues

Transparency

Hi Paul, Thanks for the great block. I noticed that the warping doesn't acknowledge transparency when the texture has alpha channel. Is there a quick fix for this? I guess I should modify the shaders. For a Perspective-Bilinear warp which shader should I modify?

Thanks a bunch

Problems when using warp->draw( videoTexture )

Hi! This block is really awesome, but I encountered two minor problems trying to warp a video.

If I use begin( ) and end( ) everything is fine. If I do warp->draw(mImage) it's also good. But when I do warp->draw(mMovie.getTexture( )) the controls are drawn in some strange blending mode (multiply?).

See the following images. I changed the grid to green:

warped image
screen shot 2013-08-29 at 1 07 55 pm

warped video texture
screen shot 2013-08-29 at 1 09 12 pm

Aside from that, I found that this line in WarpBilinear.cpp prevented me from drawing multiple warps with different alpha, so in my opinion it would be best to leave the tint color to the user.
gl::color( Color(mBrightness, mBrightness, mBrightness) )

FBO Texture Control Point Coordinate System

Since the Cinder coordinate system starts from top-left, and OpenGL starts from bottom-left, When I draw a FBO texture with warp->draw( fboTexture );, the texture is flipped. This can be solved by adding gl::setMatricesWindow( getWindowSize(), false ); before warp->draw(fboTexture).

However, the controlling points are still flipped: When I select and drag the top-left corner, I am actually selecting and dragging the bottom-left corner. This happens because the mouse coordinates returned from MouseEvent always start from top-left, and the flipped texture coordinates start from bottom-left.

I tried to add sMouse = Vec2i( event.getX(), getWindowHeight() - event.getY() ); in Warp::handleMouseDown() and Warp::handleMouseMove(), so now I can select and correct corner, but the dragging is still wrong, there are more math than I can figure out. Plus, this only works for FBO texture.

Can you adapt your Warp math so that it works for both FBO and non-FBO textures?

image fading to black?

Hi Paul, thanks for making this, it seems like it will be really cool!

I am trying to use the example and I'm finding it works except it also fades the inputted image to black in the bottom right corner. Perhaps there is something I'm missing?

Here is an attached image of when I just use the bilinear warp on the help.png image,
and I've also attached an image of what I see when I use the example app without editing at all.

Any help is appreciated (my goal is to warp the image but not have it fade to black).

Best,
Max

Here is the result with just the bilinear warp:
screen shot 2017-11-24 at 4 22 03 pm

Here is the image without modifying the example code at all:
screen shot 2017-11-24 at 4 24 42 pm

Template warps.xml

The warps.xml file for the template was not updated with the XML structure change. This results in an empty output, because no warps can be initialized.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.