実現したいこと
最終的にはARマーカの座標を取得して、そのマーカーを傾けてもその傾きにあったプロジェクションマッピングが行われるようにしたいと思っています。ProcessingでのARマーカの座標取得には成功しているのですが、keystoneを使って動的なプロジェクションマッピングをする方法がわかりません。
opencvを使った方法も検討していますのでそちらの方面のアドバイスもありがたいですが、できればkeystoneの問題解決の方法がわかれば知りたいです。
発生している問題・エラーメッセージ
今使っているコードは一番基本的なexampleです。
Cを押してキャリブレーションモードに変更し、マッピングの四方をマウスポインタで変更できますが、Processingのコードから動的に変化させる方法がわかりません。
import deadpixel.keystone.*; Keystone ks; CornerPinSurface surface; PGraphics offscreen; void setup() { // Keystone will only work with P3D or OPENGL renderers, // since it relies on texture mapping to deform size(800, 600, P3D); ks = new Keystone(this); surface = ks.createCornerPinSurface(400, 300, 20); // We need an offscreen buffer to draw the surface we // want projected // note that we're matching the resolution of the // CornerPinSurface. // (The offscreen buffer can be P2D or P3D) offscreen = createGraphics(400, 300, P3D); } void draw() { // Convert the mouse coordinate into surface coordinates // this will allow you to use mouse events inside the // surface from your screen. PVector surfaceMouse = surface.getTransformedMouse(); // Draw the scene, offscreen offscreen.beginDraw(); offscreen.background(255); offscreen.fill(0, 255, 0); offscreen.ellipse(surfaceMouse.x, surfaceMouse.y, 75, 75); offscreen.endDraw(); // most likely, you'll want a black background to minimize // bleeding around your projection area background(0); // render the scene, transformed using the corner pin surface surface.render(offscreen); } void keyPressed() { switch(key) { case 'c': // enter/leave calibration mode, where surfaces can be warped // and moved ks.toggleCalibration(); break; case 'l': // loads the saved layout ks.load(); break; case 's': // saves the layout ks.save(); break; } }
あなたの回答
tips
プレビュー