Created
March 25, 2015 01:51
-
-
Save antimodular/8ef108e3525e26311482 to your computer and use it in GitHub Desktop.
PTZ Active Camera Model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_focalLength = 60; | |
cout<<"_panAngle "<<_panAngle<<" "<<_tiltAngle<<endl; | |
float phi = _tiltAngle; //φ | |
float changeInPan;//δθ delta theta | |
float changeInTilt;//δφ | |
for(int x=0; x< sixt.getWidth(); x+=10){ | |
for(int y=0; y<sixt.getHeight(); y+=10){ | |
//changeInPanAngle = atan(x / (y+a) * sin(phi)); //setp 1 | |
cout<<"\nx y "<<x<<" , "<<y<<endl; | |
float a = _focalLength / tan(phi); //step 2 length of major axis of the inner ellipse e1 | |
cout<<"a "<<a<<endl; | |
changeInPan = atan(x / (y*sin(phi) + _focalLength * cos(phi))); //step3 | |
float b = a / sin(phi); //step 4 | |
cout<<"b "<<b<<endl; | |
float t = atan(a/b * x/(y+a)); // step 7 | |
cout<<"t "<<t<<endl; | |
float bigA = (y+a) / cos(t); //step 8 A = the major axis of e2 | |
cout<<"bigA "<<bigA<<endl; | |
changeInTilt = atan(bigA-a) / _focalLength; | |
cout<<"changeInPan "<<changeInPan<<" "<<changeInTilt<<endl; | |
sampleColor = sixt.getColor(x,y); | |
ofVec3f imageP(sixt.getWidth()-x,y,0.9); | |
imageP = cameras[4]->screenToWorld(imageP, viewMain); | |
ofQuaternion latRot, longRot; //, spinQuat; | |
latRot.makeRotate(_tiltAngle+changeInTilt, 1, 0, 0); | |
longRot.makeRotate(_panAngle+changeInPan, 0, 1, 0); | |
ofVec3f center = ofVec3f(0,0,sphereDiameter); | |
ofVec3f temp_worldPoint = latRot * longRot * center; | |
imageMesh.addVertex(temp_worldPoint); | |
imageMesh.addColor(sampleColor); | |
} | |
} | |
bGotIt = true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment