Outils pour utilisateurs

Outils du site


viconartagueye

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
viconartagueye [2012/07/04 22:11]
bvandepo [artag]
viconartagueye [2013/12/04 15:49]
bvandepo [paparazzi qt]
Ligne 168: Ligne 168:
 http://​www.gnu.org/​software/​sed/​manual/​sed.html#​Examples http://​www.gnu.org/​software/​sed/​manual/​sed.html#​Examples
  
 +=====artag 2013=====
 +
 +
 + 
 +-------------------------------------------------------------------------------------------------
 +autre version du driver nécessaire pour ma version de programme
 +
 +~/​ueye3.9/​uEye_Linux_3.90_32Bit> ​
 +  sudo sh ./​ueyesdk-setup-3.90-usb-i686.gz.run
 +  sudo /​etc/​init.d/​ueyeusbdrc start
 +
 +
 +programme dans
 +
 +~/​Desktop/​ueye/​ueye_demo3.9b> ​
 +nécessite Eigen
 +
 +sudo cp -r ~/​Desktop/​ueye/​eigen-eigen-3.0.3/​Eigen /​usr/​include/​
 +
 +
 +nécessite gdhe pour faire l'​affichage de la pose 3D (peut être pas obligatoire)
 +
 +
 +------------------------------------------------------------
 +probleme avec les fichier de calibrage distorsion_ueye_640.cal
 +il faut remplacer les points par des virgules (regler locale??) -> c'est bon!
 +
 +
 +http://​stackoverflow.com/​questions/​13489940/​stupid-bug-with-fscanf-comma-instead-of-point
 +
 +@user1773603 And probably broke everything else. The (almost) first line in any console application written in C++ should be std::​locale::​global( std::​locale( ""​ ) );; in C, this would be setlocale( LC_ALL, ""​ );
 +
 +NE MARCHE PAS!!!!
 +
 +IL faut faire: ​
 +        std::​setlocale(LC_ALL,​ "​en_US.UTF-8"​);​
 +
 +
 +
 +
 +
 +utiliser ueyedemo pour graber des images pour l'​étalonnage:​ cp /​home/​bvandepo/​Desktop/​ueye/​ueye_demo3.9b/​im*.pgm ​
 +
 +
 +
 +cat /​home/​bvandepo/​Desktop/​ueye/​ueye_demo3.9b/​distortion_ueye_640.cal
 +cp /​home/​bvandepo/​Desktop/​ueye/​ueye_demo3.9b/​distortion_ueye_640.cal distortion_ueye_640.cal.sav
 +gedit distortion_ueye_640.cal
 +
 +cp -r ~/​Desktop/​ueye/​calib/​ueye640 ~/​Desktop/​ueye/​calib/​ueye640_42
 +cp /​home/​bvandepo/​Desktop/​ueye/​ueye_demo3.9b/​im*.pgm ~/​Desktop/​ueye/​calib/​ueye640_42/​TOOLBOX_calib_TP2007
 +
 +cd ~/​Desktop/​ueye/​calib/​ueye640_42/​TOOLBOX_calib_TP2007
 +rm Calib_Results.mat ​      //​sinon probleme à l'​enregistrement ​ plus tard
 +matlab
 +
 +
 +cd ~/​Desktop/​ueye/​calib/​ueye640_42/​TOOLBOX_calib_TP2007
 +calib_gui
 +
 +
 +script pour sauver au format .cal d'​artag:​
 +je part de saving_calib_ascii.m ​ -> saving_calib_artag.m
 +cp saving_calib_ascii.m ​  ​saving_calib_artag.m ​   ​
 +
 +format de fichier: ​  ​http://​handheldar.icg.tugraz.at/​artoolkitplus.php
 +
 +http://​www.vision.caltech.edu/​bouguetj/​calib_doc/​htmls/​parameters.html
 +
 +
 +
 +
 +avant la calib, ​
 + ​est_dist=[ ​ 1 1 0 0 0 ]'
 +pour avoir uniquement la distorsion radiale à degré 2, pour les autres paramètres,​ l'​ordre n'est pas le même...
 +
 +
 +ARToolKitPlus_CamCal_Rev02
 +640 480 369,46127 220,13294 655,30253 652,92494 -0,44156 0,21704 0,00060 -0,00032 0,00000 0,0 0
 +
 +
 +--------------------------------------------------------
 +save_name = '​Calib_Results.cal';​
 +fprintf(1,'​Generating the artoolkit %s file  containing the intrinsic and extrinsic parameters...\n',​save_name)
 +fid = fopen([ save_name ],'​wt'​);​
 +%%640 480 369,46127 220,13294 655,30253 652,92494 -0,44156 0,21704 0,00060 -0,00032 0,00000 0,0 0
 +%%descriptif du format: http://​handheldar.icg.tugraz.at/​artoolkitplus.php
 +fprintf(fid,'​ARToolKitPlus_CamCal_Rev02\n'​);​
 +fprintf(fid,'​%d %d ',​nx,​ny);​
 +fprintf(fid,'​%5.15f %5.15f ',cc);
 +fprintf(fid,'​%5.15f %5.15f ',fc);
 +fprintf(fid,'​%5.15f %5.15f %5.15f %5.15f %5.15f ',kc);
 +fprintf(fid,'​0.0 ');
 +fprintf(fid,'​0 '); %%nbiter
 +fprintf(fid,'​\n'​);​
 +fclose(fid);​
 +--------------------------------------------------------
 +ARToolKitPlus_CamCal_Rev02
 +752 480 380.586510739687810 212.040391386264446 726.305644381821253 728.322368265565387 -0.428831350163733 0.180648056392733 0.004417931387798 0.002052143842308 0.0000000000000000 0 
 +
 +
 +
 +il faut remplacer . par , et ajouter un zero
 +ARToolKitPlus_CamCal_Rev02
 +752 480 380,​586510739687810 212,​040391386264446 726,​305644381821253 728,​322368265565387 -0,​428831350163733 0,​180648056392733 0,​004417931387798 0,​002052143842308 0,​0000000000000000 0 0
 +
 +cp ~/​Desktop/​ueye/​calib/​ueye640_42/​TOOLBOX_calib_TP2007/​Calib_Results.cal ​ ~/​Desktop/​ueye/​ueye_demo3.9b/​
 +
 +
 +
 +
 +AFFICHER L'​IMAGE RECTIFIEE (sans distorsion)
 +
 +
 +:​~/​openrobots/​include/​ARToolKitPlus>​ grep -nRi disto *
 +Tracker.h:​98:​ ///​ Set to true to try loading camera undistortion table from a cache file
 +Tracker.h:​100:​ *  On slow platforms (e.g. Smartphone) creation of the undistortion lookup-table
 +Tracker.h:​182:​ ///​ Changes the undistortion mode
 +Tracker.h:​185:​ * artoolkit'​s standard undistortion method is used.
 +Tracker.h:​187:​ virtual void setUndistortionMode(UNDIST_MODE nMode) = 0;
 +TrackerImpl.h:​209:​ ///​ Changes the undistortion mode
 +TrackerImpl.h:​212:​ * artoolkit'​s standard undistortion method is used.
 +TrackerImpl.h:​214:​ virtual void setUndistortionMode(UNDIST_MODE nMode);
 +TrackerImpl.h:​459:​ void buildUndistO2ITable(Camera* pCam);
 +TrackerImpl.h:​617:​ //​ camera distortion addon by Daniel
 +TrackerImpl.h:​620:​ unsigned int *undistO2ITable;​
 +TrackerImpl.h:​8976:​ //​ if the camera parameters change, the undistortion LUT has to be rebuilt.
 +TrackerImpl.h:​8979:​ if(undistO2ITable && (arImXsize!=pCam->​xsize || arImYsize!=pCam->​ysize))
 +TrackerImpl.h:​8981:​ artkp_Free(undistO2ITable);​
 +TrackerImpl.h:​8982:​ undistO2ITable = NULL;
 +TrackerImpl.h:​10181://​ Included ../​../​src/​core/​paramDistortion.cxx
 +TrackerImpl.h:​10217:​ * $Id: paramDistortion.cxx 172 2006-07-25 14:05:47Z daniel $
 +TrackerImpl.h:​10290:​ if(!undistO2ITable)
 +TrackerImpl.h:​10291:​ buildUndistO2ITable(pCam);​
 +TrackerImpl.h:​10295:​ fixedToFloat(undistO2ITable[x+y*arImXsize],​ *ix,*iy);
 +TrackerImpl.h:​10301:​AR_TEMPL_TRACKER::​buildUndistO2ITable(Camera* pCam)
 +TrackerImpl.h:​10320:​ if(undistO2ITable)
 +TrackerImpl.h:​10321:​ //​delete undistO2ITable;​
 +TrackerImpl.h:​10322:​ artkp_Free(undistO2ITable);​
 +TrackerImpl.h:​10324:​ //​undistO2ITable = new unsigned int [arImXsize*arImYsize];​
 +TrackerImpl.h:​10325:​ undistO2ITable = artkp_Alloc<​unsigned int>​(arImXsize*arImYsize);​
 +TrackerImpl.h:​10331:​ size_t numBytes = fread(undistO2ITable,​ 1, arImXsize*arImYsize*sizeof(unsigned int), fp);
 +TrackerImpl.h:​10348:​ undistO2ITable[x+y*arImXsize] = fixed;
 +TrackerImpl.h:​10355:​ fwrite(undistO2ITable,​ 1, arImXsize*arImYsize*sizeof(unsigned int), fp);
 +TrackerImpl.h:​10382://​ End of ../​../​src/​core/​paramDistortion.cxx
 +TrackerImpl.h:​10694: ​   printf("​Distotion factor = %f %f %f %f\n", param->​dist_factor[0],​
 +TrackerImpl.h:​12214:​ //​ undistortion addon by Daniel
 +TrackerImpl.h:​12217:​ undistO2ITable = NULL;
 +TrackerImpl.h:​12279:​ if(undistO2ITable)
 +TrackerImpl.h:​12280:​ artkp_Free(undistO2ITable);​
 +TrackerImpl.h:​12281:​ undistO2ITable = NULL;
 +TrackerImpl.h:​12409:​ buildUndistO2ITable(arCamera);​
 +TrackerImpl.h:​12559:​AR_TEMPL_TRACKER::​setUndistortionMode(UNDIST_MODE nMode)
 +TrackerImpl.h:​12875:​ //​ requirements for the lens undistortion table (undistO2ITable)
 +TrackerMultiMarkerImpl.h:​143:​ void setUndistortionMode(UNDIST_MODE nMode) ​ {  AR_TEMPL_TRACKER::​setUndistortionMode(nMode); ​ }
 +TrackerSingleMarkerImpl.h:​141:​ void setUndistortionMode(UNDIST_MODE nMode) ​ {  AR_TEMPL_TRACKER::​setUndistortionMode(nMode); ​ }
 +borderouge:​~/​openrobots/​include/​ARToolKitPlus> ​
 +
 +
 +
 +
 +TrackerImpl.h:​
 +
 +namespace ARToolKitPlus {
 +
 +
 +AR_TEMPL_FUNC int
 +AR_TEMPL_TRACKER::​arInitCparam(Camera *pCam)
 +{
 + // if the camera parameters change, the undistortion LUT has to be rebuilt.
 + // (this is done automatically in arParamObserv2Ideal_LUT or arParamIdeal2Observ_LUT)
 +
 +
 +
 + undistMode = UNDIST_STD;
 +
 + undistO2ITable = NULL;
 +
 +:​~/​openrobots/​include/​ARToolKitPlus>​ grep -nRi  arParamObserv2Ideal_LUT *
 +
 +TrackerImpl.h:​449:​ int arParamObserv2Ideal_LUT(Camera* pCam, ARFloat ox, ARFloat oy, ARFloat *ix, ARFloat *iy);
 +TrackerImpl.h:​8977:​ //​ (this is done automatically in arParamObserv2Ideal_LUT or arParamIdeal2Observ_LUT)
 +TrackerImpl.h:​10288:​AR_TEMPL_TRACKER::​arParamObserv2Ideal_LUT(Camera* pCam, ARFloat ox, ARFloat oy, ARFloat *ix, ARFloat *iy)
 +TrackerImpl.h:​12575:​ arParamObserv2Ideal_func = &​AR_TEMPL_TRACKER::​arParamObserv2Ideal_LUT;​
 +
 +
 +TrackerImpl.h:​10288:​
 +
 +AR_TEMPL_FUNC int
 +AR_TEMPL_TRACKER::​arParamObserv2Ideal_LUT(Camera* pCam, ARFloat ox, ARFloat oy, ARFloat *ix, ARFloat *iy)
 +{
 + if(!undistO2ITable)
 + buildUndistO2ITable(pCam);​
 +
 + int x=(int)ox, y=(int)oy;
 +
 + fixedToFloat(undistO2ITable[x+y*arImXsize],​ *ix,*iy);
 + return 0;
 +}
 +
 +
 +
 +j'ai changé :
 +        tracker->​setUndistortionMode(ARToolKitPlus::​UNDIST_LUT);​
 +en      tracker->​setUndistortionMode(ARToolKitPlus::​UNDIST_STD);​
 +
 +A LA FIN j'ai carrement mis en NONE et ca marche pas moins bien_______!!!!!!!!!
 +
 +
 +
 +
 +le choix regle une fonction parmi plusieurs: ​
 +ARPARAM_UNDIST_FUNC arParamObserv2Ideal_func;​
 +
 +
 +
 +AR_TEMPL_FUNC void
 +AR_TEMPL_TRACKER::​setUndistortionMode(UNDIST_MODE nMode)
 +{
 + undistMode = nMode;
 + switch(undistMode)
 + {
 + case UNDIST_NONE:​
 + arParamObserv2Ideal_func = &​AR_TEMPL_TRACKER::​arParamObserv2Ideal_none;​
 + //​arParamIdeal2Observ_func = arParamIdeal2Observ_none;​
 + break;
 +
 + case UNDIST_STD:
 + arParamObserv2Ideal_func = &​AR_TEMPL_TRACKER::​arParamObserv2Ideal_std;​
 + //​arParamIdeal2Observ_func = arParamIdeal2Observ_std;​
 + break;
 +
 + case UNDIST_LUT:
 + arParamObserv2Ideal_func = &​AR_TEMPL_TRACKER::​arParamObserv2Ideal_LUT;​
 + //​arParamIdeal2Observ_func = arParamIdeal2Observ_LUT;​
 + break;
 + }
 +}
 +
 +
 +
 +
 + int arParamObserv2Ideal_none(Camera* pCam, ARFloat ox, ARFloat oy, ARFloat *ix, ARFloat *iy);
 + int arParamObserv2Ideal_LUT(Camera* pCam, ARFloat ox, ARFloat oy, ARFloat *ix, ARFloat *iy);
 + int arParamObserv2Ideal_std(Camera* pCam, ARFloat ox, ARFloat oy, ARFloat *ix, ARFloat *iy);
 + int arParamIdeal2Observ_std(Camera* pCam, ARFloat ix, ARFloat iy, ARFloat *ox, ARFloat *oy);
 +
 +
 +
 +AR_TEMPL_FUNC int
 +AR_TEMPL_TRACKER::​arParamObserv2Ideal_std(Camera* pCam, ARFloat ox, ARFloat oy, ARFloat *ix, ARFloat *iy)
 +{
 + pCam->​observ2Ideal(ox,​oy,​ix,​iy);​
 + return(0);
 +}
 +
 +
 +AR_TEMPL_FUNC int
 +AR_TEMPL_TRACKER::​arParamIdeal2Observ_std(Camera* pCam, ARFloat ix, ARFloat iy, ARFloat *ox, ARFloat *oy)
 +{
 + pCam->​ideal2Observ(ix,​iy,​ox,​oy);​
 + return(0);
 +}
 +
 +
 +AR_TEMPL_FUNC int
 +AR_TEMPL_TRACKER::​arParamObserv2Ideal_none(Camera* pCam, ARFloat ox, ARFloat oy, ARFloat *ix, ARFloat *iy)
 +{
 + *ix = ox;
 + *iy = oy;
 + return(0);
 +}
 +
 +
 +
 +
 +
 +AR_TEMPL_FUNC int
 +AR_TEMPL_TRACKER::​arParamObserv2Ideal_LUT(Camera* pCam, ARFloat ox, ARFloat oy, ARFloat *ix, ARFloat *iy)
 +{
 + if(!undistO2ITable)
 + buildUndistO2ITable(pCam);​
 +
 + int x=(int)ox, y=(int)oy;
 +
 + fixedToFloat(undistO2ITable[x+y*arImXsize],​ *ix,*iy);
 + return 0;
 +}
 +
 +
 +AR_TEMPL_FUNC void
 +AR_TEMPL_TRACKER::​buildUndistO2ITable(Camera* pCam)
 +{
 + int x,y;
 + ARFloat cx,cy, ox,oy;
 + unsigned int fixed;
 + char* cachename = NULL;
 + bool loaded = false;
 +
 + if(loadCachedUndist)
 + {
 + assert(pCam->​getFileName());​
 + cachename = new char[strlen(pCam->​getFileName())+5];​
 + strcpy(cachename,​ pCam->​getFileName());​
 + strcat(cachename,​ "​.LUT"​);​
 + }
 +
 + // we have to take care here when using a memory manager that can not free memory
 + // (usually this lookup table should only be built once - unless we change camera resolution)
 + //
 + if(undistO2ITable)
 + //delete undistO2ITable;​
 + artkp_Free(undistO2ITable);​
 +
 + //​undistO2ITable = new unsigned int [arImXsize*arImYsize];​
 + undistO2ITable = artkp_Alloc<​unsigned int>​(arImXsize*arImYsize);​
 +
 + if(loadCachedUndist)
 + {
 + if(FILE* fp = fopen(cachename,​ "​rb"​))
 + {
 + size_t numBytes = fread(undistO2ITable,​ 1, arImXsize*arImYsize*sizeof(unsigned int), fp);
 + fclose(fp);​
 +
 + if(numBytes == arImXsize*arImYsize*sizeof(unsigned int))
 + loaded = true;
 + }
 + }
 +
 + if(!loaded)
 + {
 + for(x=0; x<​arImXsize;​ x++)
 + {
 + for(y=0; y<​arImYsize;​ y++)
 + {
 + arParamObserv2Ideal_std(pCam,​ (ARFloat)x, (ARFloat)y, &cx, &cy);
 + floatToFixed(cx,​cy,​ fixed);
 + fixedToFloat(fixed,​ ox,oy);
 + undistO2ITable[x+y*arImXsize] = fixed;
 + }
 + }
 +
 + if(loadCachedUndist)
 + if(FILE* fp = fopen(cachename,​ "​wb"​))
 + {
 + fwrite(undistO2ITable,​ 1, arImXsize*arImYsize*sizeof(unsigned int), fp);
 + fclose(fp);​
 + }
 + }
 +
 + delete cachename;
 +}
 +
 +
 +AR_TEMPL_FUNC int
 +AR_TEMPL_TRACKER::​arParamObserv2Ideal(Camera *pCam, ARFloat ox, ARFloat oy, ARFloat *ix, ARFloat *iy)
 +{
 + pCam->​observ2Ideal(ox,​oy,​ix,​iy);​
 + return(0);
 +}
 +
 +AR_TEMPL_FUNC int
 +AR_TEMPL_TRACKER::​arParamIdeal2Observ(Camera *pCam, ARFloat ix, ARFloat iy, ARFloat *ox, ARFloat *oy)
 +{
 + pCam->​ideal2Observ(ix,​iy,​ox,​oy);​
 + return(0);
 +}
 +
 +
 +
 +organisation ​ des parametres de artoolkit
 +
 +ligne 11251 de TrackerImpl.h
 +
 +void CameraAdvImpl::​
 +observ2Ideal(ARFloat ox, ARFloat oy, ARFloat *ix, ARFloat *iy)
 +{
 + if(undist_iterations <= 0)
 + {
 + *ix = ox;
 + *iy = oy;
 + }
 + else
 + {
 + const ARFloat xd[2] = { (ox - cc[0]) / fc[0], (oy - cc[1]) / fc[1] };
 + const ARFloat k1 = kc[0];
 + const ARFloat k2 = kc[1];
 + const ARFloat k3 = kc[4];
 + const ARFloat p1 = kc[2];
 + const ARFloat p2 = kc[3];
 +
 + ARFloat x[2] = { xd[0], xd[1] };
 + for(int kk=0; kk<​undist_iterations;​ kk++)
 + {
 + const ARFloat x0_sq = (x[0]*x[0]);​
 + const ARFloat x1_sq = (x[1]*x[1]);​
 + const ARFloat x0_x1 = (x[0]*x[1]);​
 + const ARFloat r_2 = x0_sq + x1_sq;
 + const ARFloat r_2_sq = (r_2 * r_2);
 + const ARFloat k_radial =  1 + k1 * r_2 + k2 * (r_2_sq) + k3 * (r_2*r_2_sq);​
 + const ARFloat delta_x[2] = {   ​2*p1*x0_x1 + p2*(r_2 + 2*x0_sq),
 + p1 * (r_2 + 2*x1_sq) + 2*p2*x0_x1 ​  };
 + x[0] = xd[0] - delta_x[0];
 + x[1] = xd[1] - delta_x[1];
 + x[0] /= k_radial;
 + x[1] /= k_radial;
 + }
 +
 + *ix = (x[0] * fc[0]) + cc[0];
 + *iy = (x[1] * fc[1]) + cc[1];
 +
 +
 +
 +
 +
 +
 +dans mainview.cpp
 +   float patternWidth=10; ​  //​regle la taille du tag en mm
 +    static ARToolKitPlus::​TrackerSingleMarker *tracker ;
 +
 +
 +
 +
 +
 +
 +
 +l65 de CameraAdvImpl.h,​ je commente le protected pour rendre les param de camera accessible de l'​exterieur
 +non c'est la merde...
 +
 +je fais une fonction ​ avec les paramètres en dur, a changer plus tard
 +
 +
 +toImg(float * xp11,float * yp11)
 +{
 +float cc[2];
 +float fc[2];
 +cc[0]=386.900347574709258;​
 +cc[1]=226.702053834467705;​
 +fc[0]=735.391491383619950;​
 +fc[1]=736.881605234999142;​
 +*xp11=(*xp11*fc[0])+cc[0];​
 +*yp11=(*yp11*fc[1])+cc[1];​
 +}
 +
 +
 +
 +
 +
 +l309 de TrackerSingleMarkerImpl.h
 +
 +
 +    // find best visible marker
 +    int j, k = -1;
 +    for(j = 0; j < marker_num; j++)
 +        if(marker_info[j].id!=-1 && (nPattern==-1 || nPattern==marker_info[j].id))
 +
 +nPattern=-1 ...
 +
 +
 +
 +
 + /// calculates the transformation matrix
 + /**
 + * pass the image as RGBX (32-bits) in 320x240 pixels.
 + *  if nPattern is not -1 then only this pattern is accepted
 + *  otherwise any found pattern will be used.
 + */
 + virtual int calc(const unsigned char* nImage, int nPattern=-1,​ bool nUpdateMatrix=true,​
 + ARMarkerInfo** nMarker_info=NULL,​ int* nNumMarkers=NULL);​
 +
 +
 +
  
viconartagueye.txt · Dernière modification: 2013/12/04 15:49 par bvandepo