Hey,
I’m trying to do basic augmented reality with markers on a 1080p stream from a blackmagic hdmi converter. Things have been going fine, video coming in, did a bunch of calibration for my camera…
But now the markers are are only tracked on the left side of the screen. As soon as it passes the mid point the corners are translated into another, seemingly random, position.
In the image you can see this in the process of happening: as each corner passes the mid point they are individually displaced.
What is weird is that the center point, drawn by artk.draw();
follows the markers nicely, even on the right!
Any help or Hints would be appreciated!
//--------------------------------------------------------------
void ofApp::setup(){
ofSetFrameRate(30);
cam.setup(1920, 1080, 30);
width = 1920;
height = 1080;
colorImage.allocate(width, height);
grayImage.allocate(width, height);
grayThres.allocate(width, height);
artk.setup(width, height, "cam.cal", "markerboard_480-499.cfg", 8, 6, 6, 12, 1);
threshold = 125;
artk.setThreshold(threshold);
}
//--------------------------------------------------------------
void ofApp::update(){
if(cam.update())
{
colorImage.setFromPixels(cam.getColorPixels());
grayImage = colorImage;
// apply a threshold so we can see what is going on
grayThres = grayImage;
grayThres.threshold(threshold);
// Pass in the new image pixels to artk
artk.update(grayImage.getPixels());
}
}
//--------------------------------------------------------------
void ofApp::draw(){
ofSetColor(255);
cam.drawColor();
if(showGray)
{
grayThres.draw(0, 0);
}
artk.draw();
artk.applyProjectionMatrix(1920, 1080);
// Find out how many markers have been detected
int numDetected = artk.getNumDetectedMarkers();
// Draw for each marker discovered
for(int i=0; i<numDetected; i++) {
// Set the matrix to the perspective of this marker
// The origin is in the middle of the marker
artk.applyModelMatrix(i);
ofNoFill();
ofSetLineWidth(5);
ofSetHexColor(0xffffff);
ofNoFill();
ofEnableSmoothing();
ofSetColor(255, 255, 0, 50);
for(int i=0; i<10; i++) {
ofRect(-25, -25, 50, 50);
ofTranslate(0, 0, i*1);
}
}
}