bool Kinect::beginReadAVI(string folder) { string file = folder.substr( folder.rfind("\\")+1, folder.length() - folder.rfind("\\")-1 ); file = folder + "\\" + file; string rgbFilePath = file + COLOR_REC_DATA; string rgbFramePath = file + COLOR_REC_FRAME; string depthFilePath= file + DEPTH_REC_DATA; string depthFramePath= file + DEPTH_REC_FRAME; string skeletonFilePath= file + SKELE_REC_DATA; string skeletonFramePath= file + SKELE_REC_FRAME; rgbVideoReader = VideoCapture(rgbFilePath); if( !openBinaryFile(rgbFramePath, colorFrameReader ) ) return false; if( !openBinaryFile(depthFilePath, depthFileReader ) ) return false; if( !openBinaryFile(depthFramePath, depthFrameReader ) ) return false; if( !openBinaryFile(skeletonFilePath, skeletonFileReader ) ) return false; if( !openBinaryFile(skeletonFramePath, skeletonFrameReader ) ) return false; nOriWidth = rgbVideoReader.get(CV_CAP_PROP_FRAME_WIDTH); nOriHeight = rgbVideoReader.get(CV_CAP_PROP_FRAME_HEIGHT); nTotalFrameNumber = rgbVideoReader.get(CV_CAP_PROP_FRAME_COUNT); return true; }
int menuFlashFile(uint32_t index, uint8_t event) { FRESULT fr; lcd_putsLeft(4*FH, "\012Hold [ENT] to start writing"); if (Valid == 0) { // Validate file here if ((fr = openBinaryFile(index))) { Valid = 2; } else { if ((fr = f_close(&FlashFile))) { Valid = 2; } else { Valid = 1; } if (!isValidBufferStart(Block_buffer)) { Valid = 2; } } } if (Valid == 2) { if (memoryType == MEM_FLASH) lcd_putsLeft(4*FH, "\011Not a valid firmware file! "); else lcd_putsLeft(4*FH, "\011Not a valid EEPROM file! "); if (event == EVT_KEY_BREAK(BOOT_KEY_EXIT) || event == EVT_KEY_BREAK(BOOT_KEY_MENU)) { return 0; } return -1; } if (event == EVT_KEY_LONG(BOOT_KEY_MENU)) { fr = openBinaryFile(index); return (fr == FR_OK && isValidBufferStart(Block_buffer)); } else if (event == EVT_KEY_FIRST(BOOT_KEY_EXIT)) { return 0; } return -1; }
void extern readBinData(vector<Individual*> & sample, vector<Locus*> & locus, vector<CSNP*>& SNP, vector<string>& args, bool flag) { initParameters(args, flag); checkFileExists(par.bitfile); checkFileExists(par.famfile); checkFileExists(par.snpfile); vector<Locus> ordered; //read SNP; ifstream MAP(par.snpfile.c_str(), ios::in); MAP.clear(); int c=0; while(!MAP.eof()) { Locus* loc = new Locus; MAP >> loc->chr >> loc->name >> loc->pos >> loc->bp >> loc->allele1 >> loc->allele2; if(MAP.eof()) { delete loc; continue; } // end of if MAP.eof else if (MAP.fail()) { delete loc; error("Problem reading BIM file, line " + int2str(c+1) + "\n"); } loc->freq = c++; if(loc->name!="") { locus.push_back(loc); ordered.push_back(*loc); } else delete loc; } // end of while !MAP.eof MAP.clear(); MAP.close(); if(locus.size()==0) error("No SNPs"); //stable_sort(locus.begin(), locus.end(), less<Locus*>()); stable_sort(ordered.begin(), ordered.end()); c = 0; for(int i=0; i<locus.size(); i++) { ordered[i].bp = (int)ordered[i].freq; ordered[i].chr = 1; ordered[i].freq = c++; } //resort to get lookup table stable_sort(ordered.begin(), ordered.end()); //Do we want to look at all the data; vector<int> include(0); int nl_actual = locus.size(); for(int j=0; j<ordered.size(); j++) include.push_back((int)ordered[j].freq); //mind //include mean the snp we need to check readFamFile(par.famfile, sample); ifstream BIT; bool bfile_SNP_major = openBinaryFile(par.bitfile, BIT); if(bfile_SNP_major) { for(int i=0; i<nl_actual; i++) { CSNP * newlocus = new CSNP; newlocus->one.resize(sample.size()); newlocus->two.resize(sample.size()); SNP.push_back(newlocus); } // end of for i<nl_actual } else { vector<Individual*>::iterator person = sample.begin(); while(person != sample.end()) { (*person)->one.resize(nl_actual); (*person)->one.resize(nl_actual); person++; } } // end of if bfile_SNP_major if(bfile_SNP_major) { CSNP * snp; int s = 0; while(s<locus.size()) { if(include[s]>-1) snp = SNP[include[s]]; else snp = NULL; //inner loop for individuals int indx = 0; int ss = sample.size(); while(indx<ss) { bitset<8> b; char ch[1]; BIT.read(ch,1); if(!BIT) error("Problem with BED file"); b = ch[0]; int c = 0; while(c<7 && indx<ss) { if(snp) { snp->one[indx] = b[c++]; snp->two[indx] = b[c++]; } else { c += 2; }// end of if else snp ++indx; }//end of while c<7 && index<ss }//end of while indx<ss s++; }// end of while s < locus.size par.SNP_major = true; }// end of if bfile_SNP_major else { vector<Individual*>::iterator person = sample.begin(); while(person != sample.end()) { int s = 0; while(s<locus.size()) { char ch[1]; BIT.read(ch,1); if(!BIT) error("Problem with the BED file"); bitset<8> b; b = ch[0]; int c = 0; while(c<7 && s<locus.size()) { if(include[2]>-1) { (*person)->one[include[s]] = b[c++]; (*person)->two[include[s]] = b[c++]; } else { c += 2; } s++; }// end of while c<7 && }// end of while s<locus.size person++; }// end of while person != sample.end par.SNP_major = false; }// end of else bfile_SNP_major char ch[1]; BIT.read(ch, 1); if(BIT) error("Problem with the BED file"); }