代码中有几个外部算子,没办法运行。
只能看图识代码了。
* * This example visualizes different poses * in the camera coordinate system * * A calibration plate is held at varying positions in different * orientations with respect to the camera. * The left window visualizes the pose of the camera and the calibration * plate as seen from the side. * The right windows shows how the calibration * plate appears when seen through the camera. * The crosslines show the center of the image plane. * The position of the calibration plate is described * by a 3D translation(tx,ty,tz) specifying the translation along * the x-,y-,and z-axis. Its orientation is described * by successive rotations(Rx,Ry,Rz) around the x-,y-,and z-axis. * * Different poses of the calibration plate are visualized as seen by the camera. * An ideal camera without radial distortion is assumed. * The calibration plate is held at different poses with * respect to the camera. * * The 3D-translations(tx,ty,tz) are the first 3 elements of a pose. * At the first pose,the calibration plate is moved tz=0.2 m along the z-axis of the camera * coordinate system. The z-axis points along the camera axis,i.e. away from * the viewer. The camera coordinate system is shown in the left window by the * red arrow(x-axis),green arrow(y-axis),and blue arrow(z-axis) placed on the camera. * The calibration plate is held parallel to the camera plane. * The camera plane is the xy-plane of the camera coordinate system. * The pose of the calibration plate in the camera coordinate system can also be * interpreted as a local coordinate system attached to the calibration plate. * In both windows,this local coordinate system is shown and moves with the calibration * plate. * * * First,the effect of rotations is demonstrated. The translational * components tx,ty are set to zero. Tz is set to 0.2 m to make sure * the calibration plate is visible by the camera. * * For the following rotations the order of rotation 'gba' is chosen. * It stands for Rot(x)*Rot(y)*Rot(z). * * Read from the right,the orientation of the pose * in this example is determined by always performing rotations relative to * the global(i.e.,fixed or “old”) coordinate system of the camera. * * If the chain of rotations is read from the left,the orientation of the pose * is determined by always performing rotations relative to * the local(i.e. “new”) coordinate system attached to the rotated object, * i.e. the calibration plate in this example. * * Interpreting the chain of rotations as rotations in the new,local * object coordinate system is often easier to understand * and will thus be demonstrated in this example. * * The rotation('gba') can be read as follows: * First rotate around the x-axis,then around the “new” y-axis, * and finally around the “new” z-axis. The effect of different * rotations is shown by the next calibration plate poses. * * * Second,combined translations along all three axes * and a combined rotation about all three axes are shown. * * The object is translated along the z-axis,then along * the x-axis,and the then along the the y-axis. * * After that,the object is rotated about the x-axis of the * camera_calibration coordinate system which is identical with the * x-axis of the local object coordinate system. * This results in a new calibration plate coordinate system. * Then,the calibration plate is rotated about the y-axis * of this new coordinate system. And finally a rotation about * the z-axis of the new coordinate system is performed. * * * Initialization * * First,define calibration plate and read the values for * the ideal internal camera parameters CalTabFile:='caltab_30mm.descr' IdealCamParam:=[0.0117685,0.0,7.32909e-006,7.4e-006,259,259,512,512] dev_close_window() * Get image width and heigth from camera parameters Width:=IdealCamParam[6] Height:=IdealCamParam[7] dev_open_window(0,0,Width,Height,'white',TitleWindowHandle) set_display_font(TitleWindowHandle,14,'mono','true','false') dev_set_line_width(2) dev_open_window(0,Width+12,Width,Height,'white',WindowHandle) set_display_font(WindowHandle,14,'mono','true','false') dev_set_line_width(2) gen_camera_image(TitleImage,TitleWindowHandle) * * Part I * * Demonstrate the effect of rotations * * Place calibration plate tz=0.2m away from the camera along the z-axis. create_pose(0,0.0,0.2,0,0,0,'Rp+T','gba','point',ObjInCamPose) Message:='The calibration plate is placed Tz='+ObjInCamPose[2]+' m along' Message[1]:='the z-axis of the camera coordinate system' Message[2]:='and held parallel to the camera plane.' show_camera_view(CalTabFile,IdealCamParam,ObjInCamPose,WindowHandle) show_extern_scene_view(TitleWindowHandle,CalTabFile,IdealCamParam,ObjInCamPose,Message) stop() * * Rotate by rx=60 degrees about the x-axis. * The effect is that the calibration plate is tilted towards * the left with respect to the camera plane. create_pose(0.0,0.0,0.2,60,0,0,'Rp+T','gba','point',ObjInCamPose) Message:='The plate is rotated by Rx='+ObjInCamPose[3]+'° around the x-axis' Message[1]:='(red arrow) of the local plate coordinate ' Message[2]:='system. It is NOT parallel to the camera plane.' show_camera_view(CalTabFile,IdealCamParam,ObjInCamPose,WindowHandle) show_extern_scene_view(TitleWindowHandle,CalTabFile,IdealCamParam,ObjInCamPose,Message) stop() * * Rotate by ry=45 degrees about the x-axis. * The effect is that the calibration plate is tilted towards * the left with respect to the camera plane. create_pose(0.0,0.0,0.2,0,45,0,'Rp+T','gba','point',ObjInCamPose) Message:='The plate is rotated by Ry='+ObjInCamPose[4]+'° around the y-axis' Message[1]:='(green arrow) of the local plate coordinate' Message[2]:='system. It is NOT parallel to the camera plane.' show_camera_view(CalTabFile,IdealCamParam,ObjInCamPose,WindowHandle) show_extern_scene_view(TitleWindowHandle,CalTabFile,IdealCamParam,ObjInCamPose,Message) stop() * * Rotate by rz=30 degrees about the x-axis. * This has the effect that the calibration plate is rotated * in the camera plane but is still parallel to the camera plane, * i.e. is still parallel to the xy plane of the camera * coordinate system. create_pose(0.0,0.0,0.2,0,0,30,'Rp+T','gba','point',ObjInCamPose) Message:='A rotation by Rz='+ObjInCamPose[5]+'° around the z-axis of the' Message[1]:='calibration plate coordinate system is performed.' Message[2]:='The plate is still parallel to the camera plane.' show_camera_view(CalTabFile,IdealCamParam,ObjInCamPose,WindowHandle) show_extern_scene_view(TitleWindowHandle,CalTabFile,IdealCamParam,ObjInCamPose,Message) stop() * * Part II * * Demonstrate combined translations and rotations * * Original unrotated calibration plate pose(tz=0.2m). create_pose(0.0,0.0,0.2,0,0,0,'Rp+T','gba','point',ObjInCamPose) Message:='Original unrotated calibration plate pose.' Message[1]:='A translation Tz='+ObjInCamPose[2]+' m along the z-axis' Message[2]:='of the camera coordinate system is performed.' show_camera_view(CalTabFile,IdealCamParam,ObjInCamPose,WindowHandle) show_extern_scene_view(TitleWindowHandle,CalTabFile,IdealCamParam,ObjInCamPose,Message) stop() * * Additionally move the calibration plate tx=0.015 m along the x-axis(red arrow). create_pose(0.015,0,0,0,0,0,'Rp+T','gba','point',Pose) pose_compose(ObjInCamPose,Pose,ObjInCamPose) * Resulting pose: [0.015,0,0.2,0,0,0] Message:='Additionally,the plate is moved Tx='+ObjInCamPose[0]+' m' Message[1]:='along the x-axis(red arrow) of the camera' Message[2]:='coordinate system.' show_camera_view(CalTabFile,IdealCamParam,ObjInCamPose,WindowHandle) show_extern_scene_view(TitleWindowHandle,CalTabFile,IdealCamParam,ObjInCamPose,Message) stop() * * Additionally move the calibration plate tx=0.01 m along the y-axis(green arrow). create_pose(0,0.01,0,0,0,0,'Rp+T','gba','point',Pose) pose_compose(ObjInCamPose,Pose,ObjInCamPose) * Resulting pose: [0.015,0.01,0.2,0,0,0] Message:='Additionally,the plate is moved Ty='+ObjInCamPose[1]+' m' Message[1]:='along the y-axis(green arrow) of the camera' Message[2]:='coordinate system.' show_camera_view(CalTabFile,IdealCamParam,ObjInCamPose,WindowHandle) show_extern_scene_view(TitleWindowHandle,CalTabFile,IdealCamParam,ObjInCamPose,Message) stop() * * Additionally rotate by rx=20 degrees about the x-axis. * The effect is that the calibration plate is tilted towards * the left with respect to the camera plane. create_pose(0.0,0.0,0,20,0,0,'Rp+T','gba','point',Pose) pose_compose(ObjInCamPose,Pose,ObjInCamPose) * Resulting pose: [0.015,0.01,0.2,20,0,0] Message:='Additionally,the plate is rotated by ' Message[1]:='Rx=20° around the x-axis(red arrow) ' Message[2]:='of the local plate coordinate system.' show_camera_view(CalTabFile,IdealCamParam,ObjInCamPose,WindowHandle) show_extern_scene_view(TitleWindowHandle,CalTabFile,IdealCamParam,ObjInCamPose,Message) stop() * * Additionally rotate by ry=45 degrees about the x-axis. create_pose(0.0,0.0,0,0,45,0,'Rp+T','gba','point',Pose) pose_compose(ObjInCamPose,Pose,ObjInCamPose) * Resulting pose: [0.015,0.01,0.2,20,45,0] Message:='Additionally,the plate is rotated by Ry='+ObjInCamPose[4]+'°' Message[1]:='around the y-axis(green arrow) of the' Message[2]:='local plate coordinate system.' show_camera_view(CalTabFile,IdealCamParam,ObjInCamPose,WindowHandle) show_extern_scene_view(TitleWindowHandle,CalTabFile,IdealCamParam,ObjInCamPose,Message) stop() * * Additionally rotate by ry=30 degrees about the x-axis. create_pose(0.0,0.0,0.,0,0,30,'Rp+T','gba','point',Pose) pose_compose(ObjInCamPose,Pose,ObjInCamPose) * Resulting pose: [0.015,0.01,0.2,20,45,30] Message:='The plate is rotated by Rz='+ObjInCamPose[5]+'° around' Message[1]:='the z-axis(blue arrow) of the local' Message[2]:='coordinate system of the plate.' show_camera_view(CalTabFile,IdealCamParam,ObjInCamPose,WindowHandle) show_extern_scene_view(TitleWindowHandle,CalTabFile,IdealCamParam,ObjInCamPose,Message)
本文出自勇哥的网站《少有人走的路》wwww.skcircle.com,转载请注明出处!讨论可扫码加群:


