void MainWindow::on_actionNine_Images_Average_triggered() { QString suffix[]={"1","2","3","4","5"}; QString fileNamesNineL[9]={"CamLhf0.raw","CamLhf1.raw","CamLhf2.raw","CamLvf0.raw","CamLvf1.raw","CamLvf2.raw","CamLhc.raw","CamLvc.raw","CamLbk.raw"}; QString fileNamesNineR[9]={"CamRhf0.raw","CamRhf1.raw","CamRhf2.raw","CamRvf0.raw","CamRvf1.raw","CamRvf2.raw","CamRhc.raw","CamRvc.raw","CamRbk.raw"}; unsigned char *imgL=new unsigned char[9*imageWidth*imageHeight]; unsigned char *imgR=new unsigned char[9*imageWidth*imageHeight]; int *meanL=new int[9*imageWidth*imageHeight]; int *meanR=new int[9*imageWidth*imageHeight]; for(unsigned int i=0;i<9*imageWidth*imageHeight;i++){ meanL[i]=0;meanR[i]=0; } QDir dir(workDirectory); //进入工作目录 if(!dir.exists() || workDirectory==""){ QMessageBox::warning(this,tr("Entering Workspace error!"),tr("No workspace has been opened!")); return; } for(int i=0;i<5;i++){ dir.cd(QString("NineImages")+suffix[i]); for(int j=0;j<9;j++){ readBytesFromFile(dir.absoluteFilePath(fileNamesNineL[j]).toStdString(),&imgL[j*imageWidth*imageHeight],imageWidth*imageHeight); readBytesFromFile(dir.absoluteFilePath(fileNamesNineR[j]).toStdString(),&imgR[j*imageWidth*imageHeight],imageWidth*imageHeight); for(unsigned int k=0;k<imageWidth*imageHeight;k++){ meanL[k+j*imageWidth*imageHeight] += imgL[k+j*imageWidth*imageHeight]; meanR[k+j*imageWidth*imageHeight] += imgR[k+j*imageWidth*imageHeight]; } } dir.cdUp(); } for(unsigned int i=0;i<9*imageWidth*imageHeight;i++){ imgL[i]=meanL[i]/5;imgR[i]=meanR[i]/5; } dir.mkdir("NineImages"); dir.cd("NineImages"); for(int j=0;j<9;j++){ writeBytesToFile(dir.absoluteFilePath(fileNamesNineL[j]).toStdString(),&imgL[j*imageWidth*imageHeight],imageWidth*imageHeight); writeBytesToFile(dir.absoluteFilePath(fileNamesNineR[j]).toStdString(),&imgR[j*imageWidth*imageHeight],imageWidth*imageHeight); } }
void MainWindow::projectAndCaptureAction() { //camera->grabMultiFrames(frmL,3,0); //camera->grabMultiFrames(frmR,3,1); camera->grabSingleFrame(frmL, 0); camera->grabSingleFrame(frmR, 1); QDir dir(workDirectory); //进入工作目录 if(!dir.exists() || workDirectory==""){ QMessageBox::warning(this,tr("Entering Workspace error!"),tr("No workspace has been opened!")); return; } dir.mkdir("NineImages"); //建立目录,或者已经存在 dir.mkdir("GrayCodeImages"); string fileNamesNineL[9]={"CamLhf0.raw","CamLhf1.raw","CamLhf2.raw","CamLvf0.raw","CamLvf1.raw","CamLvf2.raw","CamLhc.raw","CamLvc.raw","CamLbk.raw"}; string fileNamesNineR[9]={"CamRhf0.raw","CamRhf1.raw","CamRhf2.raw","CamRvf0.raw","CamRvf1.raw","CamRvf2.raw","CamRhc.raw","CamRvc.raw","CamRbk.raw"}; /* string fileNamesGCL[19]={"CamLwt.raw","CamLgch0.raw","CamLgch1.raw","CamLgch2.raw","CamLgch3.raw","CamLgch4.raw","CamLgch5.raw","CamLgch6.raw","CamLgch7.raw","CamLgch8.raw", "CamLgcv0.raw","CamLgcv1.raw","CamLgcv2.raw","CamLgcv3.raw","CamLgcv4.raw","CamLgcv5.raw","CamLgcv6.raw","CamLgcv7.raw","CamLgcv8.raw"}; string fileNamesGCR[19]={"CamRwt.raw","CamRgch0.raw","CamRgch1.raw","CamRgch2.raw","CamRgch3.raw","CamRgch4.raw","CamRgch5.raw","CamRgch6.raw","CamRgch7.raw","CamRgch8.raw", "CamRgcv0.raw","CamRgcv1.raw","CamRgcv2.raw","CamRgcv3.raw","CamRgcv4.raw","CamRgcv5.raw","CamRgcv6.raw","CamRgcv7.raw","CamRgcv8.raw"}; */ string fileNameWTL = "CamLwt.raw"; string fileNamesGCHL[] = {"CamLgch0.raw","CamLgch1.raw","CamLgch2.raw","CamLgch3.raw","CamLgch4.raw","CamLgch5.raw","CamLgch6.raw","CamLgch7.raw","CamLgch8.raw","CamLgch9.raw","CamLgch10.raw"}; string fileNamesGCVL[] = {"CamLgcv0.raw","CamLgcv1.raw","CamLgcv2.raw","CamLgcv3.raw","CamLgcv4.raw","CamLgcv5.raw","CamLgcv6.raw","CamLgcv7.raw","CamLgcv8.raw","CamLgcv9.raw","CamLgcv10.raw"}; string fileNameWTR = "CamRwt.raw"; string fileNamesGCHR[] = {"CamRgch0.raw","CamRgch1.raw","CamRgch2.raw","CamRgch3.raw","CamRgch4.raw","CamRgch5.raw","CamRgch6.raw","CamRgch7.raw","CamRgch8.raw","CamRgch9.raw","CamRgch10.raw"}; string fileNamesGCVR[] = {"CamRgcv0.raw","CamRgcv1.raw","CamRgcv2.raw","CamRgcv3.raw","CamRgcv4.raw","CamRgcv5.raw","CamRgcv6.raw","CamRgcv7.raw","CamRgcv8.raw","CamRgcv9.raw","CamRgcv10.raw"}; QString imgName; switch(projection->fringeType){ case HF0: dir.cd(QString("NineImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesNineL[0])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesNineR[0])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=HF1; projection->update(); projection->show(); break; case HF1: dir.cd(QString("NineImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesNineL[1])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesNineR[1])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=HF2; projection->update(); projection->show(); break; case HF2: dir.cd(QString("NineImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesNineL[2])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesNineR[2])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=VF0; projection->update(); projection->show(); break; case VF0: dir.cd(QString("NineImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesNineL[3])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesNineR[3])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=VF1; projection->update(); projection->show(); break; case VF1: dir.cd(QString("NineImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesNineL[4])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesNineR[4])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=VF2; projection->update(); projection->show(); break; case VF2: dir.cd(QString("NineImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesNineL[5])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesNineR[5])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=HC; projection->update(); projection->show(); break; case HC: dir.cd(QString("NineImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesNineL[6])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesNineR[6])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=VC; projection->update(); projection->show(); break; case VC: dir.cd(QString("NineImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesNineL[7])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesNineR[7])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=BK; projection->update(); projection->show(); break; case BK: dir.cd(QString("NineImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesNineL[8])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesNineR[8])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=WT; projection->update(); projection->show(); break; case WT: dir.cd(QString("GrayCodeImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNameWTL)); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNameWTR)); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=GCH0; projection->update(); projection->show(); break; case GCH0: dir.cd(QString("GrayCodeImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCHL[0])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCHR[0])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=GCH1; projection->update(); projection->show(); break; case GCH1: dir.cd(QString("GrayCodeImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCHL[1])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCHR[1])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=GCH2; projection->update(); projection->show(); break; case GCH2: dir.cd(QString("GrayCodeImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCHL[2])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCHR[2])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=GCH3; projection->update(); projection->show(); break; case GCH3: dir.cd(QString("GrayCodeImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCHL[3])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCHR[3])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=GCH4; projection->update(); projection->show(); break; case GCH4: dir.cd(QString("GrayCodeImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCHL[4])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCHR[4])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=GCH5; projection->update(); projection->show(); break; case GCH5: dir.cd(QString("GrayCodeImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCHL[5])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCHR[5])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=GCH6; projection->update(); projection->show(); break; case GCH6: dir.cd(QString("GrayCodeImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCHL[6])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCHR[6])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=GCH7; projection->update(); projection->show(); break; case GCH7: dir.cd(QString("GrayCodeImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCHL[7])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCHR[7])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=GCH8; projection->update(); projection->show(); break; case GCH8: dir.cd(QString("GrayCodeImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCHL[8])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCHR[8])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=GCH9; projection->update(); projection->show(); break; case GCH9: dir.cd(QString("GrayCodeImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCHL[9])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCHR[9])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=GCV0; projection->update(); projection->show(); break; case GCV0: dir.cd(QString("GrayCodeImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCVL[0])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCVR[0])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=GCV1; projection->update(); projection->show(); break; case GCV1: dir.cd(QString("GrayCodeImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCVL[1])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCVR[1])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=GCV2; projection->update(); projection->show(); break; case GCV2: dir.cd(QString("GrayCodeImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCVL[2])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCVR[2])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=GCV3; projection->update(); projection->show(); break; case GCV3: dir.cd(QString("GrayCodeImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCVL[3])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCVR[3])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=GCV4; projection->update(); projection->show(); break; case GCV4: dir.cd(QString("GrayCodeImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCVL[4])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCVR[4])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=GCV5; projection->update(); projection->show(); break; case GCV5: dir.cd(QString("GrayCodeImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCVL[5])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCVR[5])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=GCV6; projection->update(); projection->show(); break; case GCV6: dir.cd(QString("GrayCodeImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCVL[6])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCVR[6])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=GCV7; projection->update(); projection->show(); break; case GCV7: dir.cd(QString("GrayCodeImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCVL[7])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCVR[7])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=GCV8; projection->update(); projection->show(); break; case GCV8: dir.cd(QString("GrayCodeImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCVL[8])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCVR[8])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=GCV9; projection->update(); projection->show(); break; case GCV9: dir.cd(QString("GrayCodeImages")); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCVL[9])); writeBytesToFile(imgName.toStdString(),frmL,imageWidth*imageHeight); imgName=dir.absoluteFilePath(QString::fromStdString(fileNamesGCVR[9])); writeBytesToFile(imgName.toStdString(),frmR,imageWidth*imageHeight); projection->fringeType=-1; projection->update(); projection->hide(); pcTimer->stop(); break; default: QMessageBox::warning(this,QString("Project and Capture Error"),QString("Fringe type is wrong!")); break; } }
int main_databinder(int argc, char *argv[]) { struct v2gEXIDocument exiDoc; int errn = 0; bitstream_t iStream, oStream; #if EXI_STREAM == BYTE_ARRAY uint16_t posDecode; uint16_t posEncode; #endif /* EXI_STREAM == BYTE_ARRAY */ #if EXI_DEBUG == 1 /* The Eclipse console has buffering problems on Windows e.g, Debug mode */ setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0); #endif /*EXI_DEBUG*/ if (argc != 3) { printf("Usage: %s exiInput exiOutput\n", argv[0]); return -1; } #if EXI_STREAM == BYTE_ARRAY /* input pos */ posDecode = 0; /* parse EXI stream to internal byte structures */ errn = readBytesFromFile(argv[1], bufferIn, BUFFER_SIZE, &posDecode); if (errn != 0) { printf("Problems while reading file into buffer, err==%d\n", errn); return errn; } posDecode = 0; /* reset position */ #endif /* EXI_STREAM == BYTE_ARRAY */ /* setup input stream */ #if EXI_STREAM == BYTE_ARRAY iStream.size = BUFFER_SIZE; iStream.data = bufferIn; iStream.pos = &posDecode; #endif /* EXI_STREAM == BYTE_ARRAY */ iStream.buffer = 0; iStream.capacity = 0; printf("Start decoding EXI stream to databinding layer \n"); errn = decode_v2gExiDocument(&iStream, &exiDoc); if (errn != 0) { printf("Problems while decoding EXI stream, err==%d\n", errn); return errn; } #if EXI_STREAM == BYTE_ARRAY /* setup output stream */ posEncode = 0; oStream.size = BUFFER_SIZE; oStream.data = bufferOut; oStream.pos = &posEncode; #endif oStream.buffer = 0; oStream.capacity = 8; printf("Start encoding databinding layer to EXI \n"); errn = encode_v2gExiDocument(&oStream, &exiDoc); if (errn != 0) { printf("Problems while encoding databinding layer, err==%d\n", errn); return errn; } printf("EXI roundtrip done with success\n"); #if EXI_STREAM == BYTE_ARRAY /* write to file */ writeBytesToFile(oStream.data, posEncode, argv[2]); #endif return errn; }