TEST(Obis, Obis_strparsing) { Obis o1(0x1, 0x1, 97, 97, 0xff, 0xff); // 97 = SC_F Obis o2("1-1:F.F"); ASSERT_EQ(o1, o2); Obis o3(0x1, 0x1, 96, 98, 0xff, 0xff); // 96 = SC_C, 98 = SC_L Obis o4("1-1:C.L"); ASSERT_EQ(o3, o4); Obis o5(0x1, 0x1, 96, 99, 0xff, 0xff); // 96 = SC_C, 99 = SC_P Obis o6("1-1:C.P"); ASSERT_EQ(o5, o6); ASSERT_THROW(Obis o7("1-1:x:y"), vz::VZException); Obis o8("power-l1"); ASSERT_EQ(Obis("1-0:21.7"), o8); }
/* Finds the median-of-seven in the array spanning **left to **right * and puts the value in *pivot_ptr. */ static yes_no find_pivot_7(char **left, char **right, char **pivot_ptr) { char **p; int step = (right - left) / 6; char *a = *left; char *b = *(left + step); char *c = *(left + step + step); char *d = *(left + step + step + step); char *e = *(left + step + step + step + step); char *f = *(left + step + step + step + step); char *g = *right; o7(a, b, c, d, e, f, g); if (strcmp(a, d) == -1) { *pivot_ptr = d; return yes; } if (strcmp(d, e) == -1) { *pivot_ptr = e; return yes; } if (strcmp(e, f) == -1) { *pivot_ptr = f; return yes; } if (strcmp(f, g) == -1) { *pivot_ptr = g; return yes; } for (p = left + 1; p <= right; ++p) { if (strcmp(*p, *left) != 0) { *pivot_ptr = (strcmp(*p, *left) == -1) ? *left : *p; return yes; } } return no; }
TEST(Obis, Obis_extStrParsing) { Obis o1(0xff, 0xff, 0x0, 0x0, 0x0, 0xff); Obis o2("0.0.0"); ASSERT_EQ(o1, o2) << o1.toString( )<< o2.toString(); ASSERT_EQ(o1.toString(), o2.toString()); Obis o3(0xff, 0xff, 0x1, 0x2, 0x3, 0xff); Obis o4("1.2.3"); ASSERT_EQ(o3, o4); ASSERT_EQ(o3.toString(), o4.toString()); Obis o5(0xff, 0xff, 0x61, 0x61, 0xff, 0xff); Obis o6("F.F"); ASSERT_EQ(o5, o6); Obis o7(0xff, 0xff, 0x0, 0x0, 0x2, 0xff); Obis o8("0.0.2"); ASSERT_EQ(o7, o8); // this should throw an exception as hex codes are not valid inside obis codes. ASSERT_THROW(Obis o10("1.8.0*FF"), vz::VZException); ASSERT_THROW(Obis o10("1.8.0*F1"), vz::VZException); }
bool SparseRec2View::save() { if(!_onlymatch) { //save reconstructed points string path1(dir+imgname1+string("-")+imgname2+string(".X")); std::ofstream o1(path1.c_str()); o1 << "VERTEX " << (int)results.size() << endl; for(int i=0; i<(int)results.size(); ++i) { o1<<results[i].x<<" "<<results[i].y<<" "<<results[i].z<<endl; } o1.close(); TagI("save reconstructed points to\n %s\n",path1.c_str()); //save cam par string path7(imgpath1+string(".par")); std::ofstream o7(path7.c_str()); o7.setf(std::ios::scientific); o7 << "K(alphaX alphaY u0 v0)=" <<endl; o7 << K[0] << " " << K[4] << " " << K[2] << " " << K[5] << endl; o7 << "R=" << endl; o7 << "1 0 0\n0 1 0\n0 0 1" <<endl; o7 << "T=" << endl; o7 << "0 0 0" << endl; o7.close(); TagI("save camera 1's parameters to\n %s\n",path7.c_str()); string path8(imgpath2+string(".par")); std::ofstream o8(path8.c_str()); o8.setf(std::ios::scientific); o8 << "K(alphaX alphaY u0 v0)=" <<endl; o8 << K[0] <<" "<< K[4] <<" "<< K[2] <<" "<< K[5] << endl; o8 << "R=" << endl; for(int i=0; i<3; ++i) { for(int j=0; j<3; ++j) { o8 << R[i*3+j] << " "; } o8 << endl; } o8 << "T=" << endl; o8 << t[0] <<" "<< t[1] <<" "<< t[2] << endl; o8.close(); TagI("save camera 2's parameters to\n %s\n",path8.c_str()); } double fontScale=0.5; CvPoint text_origin; //save matched point pairs string path2(dir+imgname1+string("-")+imgname2+string(".p1p2")); std::ofstream o2(path2.c_str()); //out.setf(std::ios::scientific); int cnt = 0; for(int i=0; i<(int)p1.size(); ++i) { if(!inliers[i]) continue; o2 << p1[i].x <<" "<< p1[i].y <<" "<< p2[i].x <<" "<< p2[i].y <<endl; char tmp[256]; sprintf(tmp, "%d", cnt++); text_origin.x = (int)p1[i].x+5; text_origin.y = (int)p1[i].y-5; putText(img1, tmp, text_origin, CV_FONT_HERSHEY_PLAIN, fontScale, CV_BLACK); text_origin.x = (int)p2[i].x+5; text_origin.y = (int)p2[i].y-5; putText(img2, tmp, text_origin, CV_FONT_HERSHEY_PLAIN, fontScale, CV_BLACK); } o2.close(); TagI("save matched point pairs to\n %s\n",path2.c_str()); //save images string path3(imgpath1+string("-detect.jpg")); string path4(imgpath2+string("-detect.jpg")); string path5(dir+imgname1+string("-")+imgname2+string(".jpg")); if(!img1.empty()) cv::imwrite(path3, img1); else { TagE("no valid image to save!\n"); return false; } if(!img2.empty()) cv::imwrite(path4, img2); if(!combined.empty()) cv::imwrite(path5, combined); TagI("save surfed image 1 to\n %s\n",path3.c_str()); TagI("save surfed image 2 to\n %s\n",path4.c_str()); TagI("save combined image to\n %s\n",path5.c_str()); //save F string path6(dir+imgname1+string("-")+imgname2+string(".fmatrix")); std::ofstream o6(path6.c_str()); o6 << helper::PrintMat<>(3,3,F); o6.close(); TagI("save fundamental matrix to\n %s\n",path6.c_str()); return true; }
int go(int argc){ seal::PluginManager::get()->initialise(); pool::URIParser p; p.parse(); pool::IFileCatalog lcat; pool::IFileCatalog * cat = &lcat; cat->setWriteCatalog(p.contactstring()); cat->connect(); cat->start(); pool::IDataSvc *svc = pool::DataSvcFactory::instance(cat); // Define the policy for the implicit file handling pool::DatabaseConnectionPolicy policy; policy.setWriteModeForNonExisting(pool::DatabaseConnectionPolicy::CREATE); // policy.setWriteModeForExisting(pool::DatabaseConnectionPolicy::OVERWRITE); policy.setWriteModeForExisting(pool::DatabaseConnectionPolicy::UPDATE); svc->session().setDefaultConnectionPolicy(policy); svc->transaction().start(pool::ITransaction::UPDATE); std::vector<pool::Ref<TT<T1> > > refs; std::string vten[] = { "0","1","2","3","4","5","6","7","8","9","10"}; std::vector<std::string> ten(vten,vten+11); std::vector<std::string>::const_iterator s = ten.begin(); for (;s!=ten.end();s++) { std::string f = std::string("E")+ (*s); std::string c = std::string("C")+ (*s); pool::Ref<TT<T1> > o1(svc, new TT<T1>); pool::Placement place(f, pool::DatabaseSpecification::PFN, c, ROOT::Reflex::Type(), pool::ROOTKEY_StorageType.type()); // This will also register the file. For this to occur, the placement object must use a PFN. o1.markWrite(place); refs.push_back(o1); } pool::Ref<TMe > o6(svc, new TMe); { pool::Placement place("E0", pool::DatabaseSpecification::PFN, "C0", ROOT::Reflex::Type(), pool::ROOTKEY_StorageType.type()); // This will also register the file. For this to occur, the placement object must use a PFN. o6.markWrite(place); } pool::Ref<TVoid> o7(svc, new TVoid); { pool::Placement place("E0", pool::DatabaseSpecification::PFN, "C0", ROOT::Reflex::Type(), pool::ROOTKEY_StorageType.type()); // This will also register the file. For this to occur, the placement object must use a PFN. o7.markWrite(place); } svc->transaction().commit(); svc->session().disconnectAll(); // cat->commit(); // cat->start(); svc->transaction().start(pool::ITransaction::UPDATE); pool::Ref<TT<T1> > o1(svc, new TT<T1>); { pool::Placement place("DN", pool::DatabaseSpecification::PFN, "L", ROOT::Reflex::Type(), pool::ROOTKEY_StorageType.type()); // This will also register the file. For this to occur, the placement object must use a PFN. o1.markWrite(place); } pool::Ref<TT<T2> > o2(svc, new TT<T2>); { pool::Placement place("EN", pool::DatabaseSpecification::PFN, "N", ROOT::Reflex::Type(), pool::ROOTKEY_StorageType.type()); // This will also register the file. For this to occur, the placement object must use a PFN. o2.markWrite(place); } // o1->bs.push_back(o2); // o2->c=o1; pool::Collection<TT<T1> > collection(svc, "ImplicitCollection", "PFN:DN", "L", pool::ICollection::READ) ; pool::Collection<TT<T1> >::Iterator iter = collection.select(); while (iter.next()) { std::cout << iter.ref().toString() << std::endl; std::cout << (*iter).i << std::endl; } std::vector<pool::Ref<TT<T1> > >::const_iterator r = refs.begin(); int n=0; for (;r!=refs.end();r++) { n++; std::cout << r->toString() << std::endl; if (n==2||n==8) r->markUpdate(); } svc->transaction().commit(); svc->session().disconnectAll(); svc->cacheSvc().resetCache(); svc->transaction().start(pool::ITransaction::READ); std::cout << "o6 " << o6.isNull() << " " << (*o6->me.get()).i << std::endl; std::cout << "o7 " << o7.isNull() << " " << (*o7->get()).i << std::endl; svc->transaction().commit(); svc->session().disconnectAll(); cat->commit(); delete svc; return 0; }
/* * START THE VM */ void startVM(Vm* vm) { vm->PC = 0; while (charArrayToInt(0,2,vm->IR) != 99) { nextInstruction(vm); switch (charArrayToInt(0,2,vm->IR)) { case 0: o0(vm); break; case 1: o1(vm); break; case 2: o2(vm); break; case 3: o3(vm); break; case 4: o4(vm); break; case 5: o5(vm); break; case 6: o6(vm); break; case 7: o7(vm); break; case 8: o8(vm); break; case 9: o9(vm); break; case 10: o10(vm); break; case 11: o11(vm); break; case 12: o12(vm); break; case 13: o13(vm); break; case 14: o14(vm); break; case 15: o15(vm); break; case 16: o16(vm); break; case 17: o17(vm); break; case 18: o18(vm); break; case 19: o19(vm); break; case 20: o20(vm); break; case 21: o21(vm); break; case 22: o22(vm); break; case 23: o23(vm); break; case 24: o24(vm); break; case 25: o25(vm); break; case 26: o26(vm); break; case 27: o27(vm); break; case 28: o28(vm); break; case 29: o29(vm); break; case 30: o30(vm); break; case 31: o31(vm); break; case 32: o32(vm); break; case 33: o33(vm); break; case 34: o34(vm); break; case 35: o35(vm); break; case 99: o99(vm); break; default: // Code break; } displayVmFinal(vm); } }