int strategy( const int hd[], const int fd[], int cg, int tk, const int ud[], int us) { int i ; // 反復変数 int ret = -1; // 交換する手札 Separate_hand( hd ); Separate_dishand( ud, us ); //=========== デッキの残りを sut,num に分ける前の 元の数字 で調べる ================== for( i=0; i<52; i++){ deck_flg[i] = 0; } // フラグの初期化 for( i=0; i<us; i++){ deck_flg[ud[i]] = 1; } // 捨て札から 山札候補を見つける for( i=0; i<HNUM; i++ ){ deck_flg[hd[i]] = 1; } // 手札から 山札候補を見つける /* テイクは0-5まで */ ch = Reach_check(); // 中で Check_len(); を呼び出している if( tk < 2 ){ // 1回目と2回目のゲームは捨てる ただし、リーチの場合は続ける if( ch == 1 ){ // ストレートへ // return Straight(hd,cg,us); return Flush(hd,cg,us); }else if( ch == 2 ){ // フラッシュへ return Flush(hd,cg,us); }else{ return -1; } } if( tk == 3 && 52-HNUM-us <= 22) { return -1; } if( tk == 5 ){ ret = Final(hd,cg,us); } if( ret == -1 ){ ret = Flush(hd,cg,us); } // 返却値は必ず 0-4 の値 return ret; }
Player::Player(QWidget *parent): QDialog(parent) { setupUi(this); this->setMaximumSize(20000,200); //this->setMinimumSize(0,200); streamrender = new StreamRender(this); connect(streamrender, SIGNAL(Finish()),this, SLOT(Final())); streamrender->setVumeter(this->vumeter); streamrender->setSlider(this->slider); streamrender->setLabel(this->label); connect(BtnPlay,SIGNAL(clicked()),this, SLOT(Play())); connect(BtnPause,SIGNAL(clicked()),this, SLOT(Pause())); connect(BtnStop,SIGNAL(clicked()),this, SLOT(Stop())); connect(BtnAtras,SIGNAL(clicked()),streamrender, SLOT(SlideBack())); connect(BtnAlante,SIGNAL(clicked()),streamrender, SLOT(SlideForward())); connect(BtnEncadenar,SIGNAL(clicked(bool)),streamrender, SLOT(setEncadenar(bool))); this->button= new Button(this); // temporal para los colores this->button->setVisible(false); }
void reduce_measurement_g2o::add_icp_measurement(int i, int j) { Sophus::SE3f Mij = frames[i]->get_pos().inverse() * frames[j]->get_pos(); pcl::PointCloud<pcl::PointNormal>::Ptr Final( new pcl::PointCloud<pcl::PointNormal>); pcl::PointCloud<pcl::PointNormal>::Ptr cloud_j = frames[j]->get_pointcloud_with_normals(8, false); pcl::PointCloud<pcl::PointNormal>::Ptr cloud_i = frames[i]->get_pointcloud_with_normals(8, false); pcl::transformPointCloudWithNormals(*cloud_j, *cloud_j, Mij.matrix()); icp.setInputCloud(cloud_j); icp.setInputTarget(cloud_i); icp.align(*Final); if (icp.hasConverged()) { Eigen::Affine3f tm(icp.getFinalTransformation()); Mij = Sophus::SE3f(tm.rotation(), tm.translation()) * Mij; measurement meas; meas.i = i; meas.j = j; meas.transform = Mij; meas.mt = ICP; m.push_back(meas); } }
void multiKinectCalibration::calibrate() { if (!useTFonly) { std::cerr << "Available PCL: "<<iterationStep << " " << listOfPointCloudnames.size() << std::endl; for (std::size_t i = 1; i < listOfPointCloudnames.size(); i++) { // refine the transformation with ICP std::cerr << "Aligning kinect" << 1 << " with kinect" << i+1 << std::endl; std::cerr << "Initial Pose est:\n" << kinect2kinectTransform[i-1].matrix() << std::endl; pcl::IterativeClosestPoint<pcl::PointXYZRGBA, pcl::PointXYZRGBA> icp; icp.setInputCloud(cachedPCL[i]); icp.setInputTarget(cachedPCL[0]); pcl::PointCloud<pcl::PointXYZRGBA>::Ptr Final(new pcl::PointCloud<pcl::PointXYZRGBA>()); std::cerr << "Starting ICP between kinect" << 1 << " with kinect" << i+1 << std::endl; icp.align(*Final, kinect2kinectTransform[i-1].inverse().matrix().cast<float>()); std::cerr << "ICP has converged. Final transformation:\n"; std::cerr << icp.getFinalTransformation().inverse() << std::endl; // dump the ICP transformation kinect2kinectTransform[i - 1] = icp.getFinalTransformation().inverse().cast<double>(); std::stringstream ss; ss << dumpLocation << "Aligned" << i << ".pcd"; pcl::PCDWriter writer; writer.write<pcl::PointXYZRGBA> (ss.str(), *Final, true); showPCL(Final); } } else std::cerr << "using tf only"; dumpParams(); }
HashReturn Hash(int hashbitlen, const BitSequence *data, DataLength databitlen, BitSequence *hashval) { hashState state; if (Init(&state,hashbitlen) != SUCCESS) return BAD_HASHBITLEN; Update(&state,data,databitlen); return Final(&state,hashval); }
HashReturn Hash(int hashbitlen, const BitSequence *data, DataLength databitlen, BitSequence *hashval) { HashReturn hRet; hashState hs; ///// /* __m128i a, b, c, d, t[4], u[4], v[4]; a = _mm_set_epi32(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); b = _mm_set_epi32(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110); c = _mm_set_epi32(0x2f2e2d2c, 0x2b2a2928, 0x27262524, 0x23222120); d = _mm_set_epi32(0x3f3e3d3c, 0x3b3a3938, 0x37363534, 0x33323130); t[0] = _mm_unpacklo_epi8(a, b); t[1] = _mm_unpackhi_epi8(a, b); t[2] = _mm_unpacklo_epi8(c, d); t[3] = _mm_unpackhi_epi8(c, d); u[0] = _mm_unpacklo_epi16(t[0], t[2]); u[1] = _mm_unpackhi_epi16(t[0], t[2]); u[2] = _mm_unpacklo_epi16(t[1], t[3]); u[3] = _mm_unpackhi_epi16(t[1], t[3]); t[0] = _mm_unpacklo_epi16(u[0], u[1]); t[1] = _mm_unpackhi_epi16(u[0], u[1]); t[2] = _mm_unpacklo_epi16(u[2], u[3]); t[3] = _mm_unpackhi_epi16(u[2], u[3]); u[0] = _mm_unpacklo_epi8(t[0], t[1]); u[1] = _mm_unpackhi_epi8(t[0], t[1]); u[2] = _mm_unpacklo_epi8(t[2], t[3]); u[3] = _mm_unpackhi_epi8(t[2], t[3]); a = _mm_unpacklo_epi8(u[0], u[1]); b = _mm_unpackhi_epi8(u[0], u[1]); c = _mm_unpacklo_epi8(u[2], u[3]); d = _mm_unpackhi_epi8(u[2], u[3]); */ ///// hRet = Init(&hs, hashbitlen); if(hRet != SUCCESS) return hRet; hRet = Update(&hs, data, databitlen); if(hRet != SUCCESS) return hRet; hRet = Final(&hs, hashval); if(hRet != SUCCESS) return hRet; return SUCCESS; }
int crypto_hash( unsigned char *out, const unsigned char *in, unsigned long long inlen ) { #if 1 tSmallUInt i; tSmallUInt len; unsigned char * pState; tKeccakLane state[5 * 5]; memset( state, 0, sizeof(state) ); /* Full blocks */ for ( /* empty */; inlen >= cKeccakR_SizeInBytes; inlen -= cKeccakR_SizeInBytes ) { in = xorLanes( state, in, cKeccakR_SizeInBytes / 8 ); KeccakF( state ); } /* Last uncomplete block */ len = (tSmallUInt)inlen; xorBytes( state, in, len ); pState = (unsigned char*)state + len; /* Padding */ for ( i = 0; i < 4; /* empty */ ) { *(pState++) ^= pgm_read_byte(&KeccakPadding[i++]); if ( ++len == cKeccakR_SizeInBytes ) { KeccakF( state ); pState = (unsigned char*)state; len = 0; } } if ( len != 0 ) { KeccakF( state ); } memcpy( out, state, crypto_hash_BYTES ); return ( 0 ); #else hashState state; Init( &state ); Update( &state, in, inlen * 8 ); return (Final( &state, out, crypto_hash_BYTES ) ); #endif }
void Context::Close() { if (m_pVideo) NotifyVideoEOS(0); if (m_pAudio) NotifyAudioEOS(0); Final(); }
void PlanetHelper::GenerateImage() { ParseData(2, 2, 2, 2, Radius, Array); sf::Color C; sf::Color Last; for(int x=0; x<Radius*2; x++) { for(int y=0; y<Radius*2; y++) { if((sqrt(pow(x-Radius, 2)+pow(y-Radius,2)))<Radius) { sf::Color Final(0,0,0); Last=Final; Final=GetColoursFromHeightmap(x, y); int Check=0; int LastCheck=0; int xlowerlim=1, xupperlim=1, ylowerlim=1, yupperlim=1; if(x+-xlowerlim>0 && x+xlowerlim<Radius*2 ) { for(int i=-xlowerlim; i<xupperlim+1; i++) { Check=ReturnTier(x+i, y); LastCheck=ReturnTier(x+i-1, y); if(Check!=LastCheck) { Final=GetColoursFromHeightmap(x-1, y); #ifdef SHADING set_pixel_with_variance((Final.r+Last.r)/2, (Final.g+Last.g)/2, (Final.b+Last.b)/2,Array[x-1][y], x-1, y, Image); #endif } } } Check=0; if(y+-ylowerlim>0 && y+ylowerlim<Radius*2 ) { for(int i=-ylowerlim; i<yupperlim+1; i++) { Check=ReturnTier(x, y+i); LastCheck=ReturnTier(x, y+i-1); if(Check!=LastCheck) { Final=GetColoursFromHeightmap(x, y-1); #ifdef SHADING set_pixel_with_variance((Final.r+Last.r)/2, (Final.g+Last.g)/2, (Final.b+Last.b)/2,Array[x][y-1], x, y-1, Image); #endif } } } SetPixelWithVariance(Final.r, Final.g, Final.b, x, y, 1, Image); } else { SetPixelWithVariance(255, 0, 255, x, y, 1, Image); } } } }
char* SHA1::digestFile(QFile *file) { int length; __UINT8_TYPE__ buffer[1024]; while(length = file->read((char *)buffer, 1024)) Update(buffer, length); Final(); return digestChars; }
int Context::EOS(Stream*) { assert(m_cEOS > 0); --m_cEOS; if (m_cEOS > 0) return 0; Final(); return 1; //signal done }
HashReturn Hash( int hashbitlen, const BitSequence *data, DataLength databitlen, BitSequence *hashval ) { int err; md6_state state; if ((err = Init( &state, hashbitlen ))) return err; if ((err = Update( &state, data, databitlen ))) return err; return Final( &state, hashval ); }
bool NFCNet::Reset() { if (!mbServer) { Final(); InitClientNet(); return true; } return true; }
void UpdateAI(const uint32 diff) { if (uiTimer <= diff) { if (bIntro) Intro(); if (bFinal) Final(); if (instance->GetBossState(DATA_UMBRA) == DONE) bFinal = true; } else (uiTimer -= diff); }
/* hash bit sequence */ void groestl(const BitSequence* data, DataLength databitlen, BitSequence* hashval) { hashState context; /* initialise */ Init(&context); /* process message */ Update(&context, data, databitlen); /* finalise */ Final(&context, hashval); }
static int compress_echo (uint8_t *out, const uint8_t *blocks[], unsigned int blocks_to_comp) { hashState s; if (Init (&s, 8*ECHO_BLOCK_SIZE)) return ERROR_ECHO; for (unsigned int i = 0; i < blocks_to_comp; i++) { if (Update (&s, blocks[i], ECHO_BLOCK_SIZE)) return ERROR_ECHO; } if (Final (&s, out)) return ERROR_ECHO; return ERROR_NONE; }
int crypto_hash(unsigned char *out, const unsigned char *in, unsigned long long len) { int ret; context ctx; /* initialise */ if ((ret = Init(&ctx)) < 0) return ret; /* process message */ if ((ret = Update(&ctx, in, len)) < 0) return ret; /* finalise */ ret = Final(&ctx, out); return ret; }
/* hash bit sequence */ HashReturn Hash(int hashbitlen, const BitSequence* data, DataLength databitlen, BitSequence* hashval) { HashReturn ret; hashState ctx; /* initialise */ if ((ret = Init(&ctx, hashbitlen))) return ret; #ifndef TURN_OFF_PRINTING char str[1+(databitlen+7)/8]; str[(databitlen+7)/8] = 0; memcpy(str, data, (databitlen+7)/8); printf("########################################\n\n"); printf("Groestl\n"); printf(" Message Digest Length = %d\n\n", hashbitlen); printf("########################################\n\n\n"); printf("%d-Block Message Sample\n\n", (int)(1+(databitlen+8*LENGTHFIELDLEN)/(8*ctx.statesize))); printf(" Input Message = \"%s\"\n\n", str); printf("========================================\n\n"); printf("Initial state:\n"); PrintState(&ctx, ctx.chaining); printf("\n"); #endif /* process message */ if ((ret = Update(&ctx, data, databitlen))) return ret; /* finalise */ ret = Final(&ctx, hashval); #ifndef TURN_OFF_PRINTING printf("\n----------------------------------------\n\n"); printf("Message Digest is\n"); PrintHash(hashval, hashbitlen); #endif return ret; }
/* hash bit sequence */ HashReturn Hash(int hashbitlen, const BitSequence* data, DataLength databitlen, BitSequence* hashval) { HashReturn ret; hashState context; /* initialise */ if ((ret = Init(&context)) != SUCCESS) return ret; /* process message */ if ((ret = Update(&context, data, databitlen)) != SUCCESS) return ret; /* finalise */ ret = Final(&context, hashval); return ret; }
HashReturn Hash(int hashbitlen, const BitSequence *data, DataLength databitlen, BitSequence *hashval) { int siz, idx; hashState state; if (hashbitlen <= 0) {return BAD_HASHBITLEN; } /* Blank out the state, just in case of some weird memory leak */ siz = sizeof(state); for (idx = 0; idx < siz; idx++) { ((unsigned char*)&state)[idx] = 0x00; } Init(&state, hashbitlen); Update(&state, data, databitlen); Final(&state, hashval); return SUCCESS; }
Final const static zero() { return Final(); }
CBlowfish::~CBlowfish() { Final(); }
int main() { { try { A a(3); std::throw_with_nested(a); assert(false); } catch (const A& a) { assert(a == A(3)); } } { try { A a(4); std::throw_with_nested(a); assert(false); } catch (const std::nested_exception& e) { assert(e.nested_ptr() == nullptr); } } { try { B b(5); std::throw_with_nested(b); assert(false); } catch (const B& b) { assert(b == B(5)); } } { try { B b(6); std::throw_with_nested(b); assert(false); } catch (const std::nested_exception& e) { assert(e.nested_ptr() == nullptr); const B& b = dynamic_cast<const B&>(e); assert(b == B(6)); } } { try { int i = 7; std::throw_with_nested(i); assert(false); } catch (int i) { assert(i == 7); } } #if __cplusplus > 201103L { try { std::throw_with_nested(Final()); assert(false); } catch (const Final &f) { } } #endif }
pcl::PointCloud<PointT>::Ptr Meshing(const std::vector< pcl::PointCloud<PointT>::Ptr > &cloud_set, const std::vector< KEYSET > &keypt_set, const std::vector< cv::Mat > &keydescr_set) { int frame_num = cloud_set.size(); if( frame_num <= 0 ) return pcl::PointCloud<PointT>::Ptr (new pcl::PointCloud<PointT>()); PointT dummy; dummy.x = 0;dummy.y = 0;dummy.z = 0; std::vector< pcl::PointCloud<PointT>::Ptr > keypt_cloud(frame_num); std::vector< pcl::PointCloud<PointT>::Ptr > cloud_f_set(frame_num); std::vector< cv::Mat > key_active_set(frame_num); for(int i = 0 ; i < frame_num ; i++ ) { int w = cloud_set[i]->width; int h = cloud_set[i]->height; keypt_cloud[i] = pcl::PointCloud<PointT>::Ptr (new pcl::PointCloud<PointT>()); std::vector< cv::Mat > mat_tmp; for( size_t j = 0 ; j < keypt_set[i].size() ; j++ ) { int cur_y = round(keypt_set[i][j].pt.y); int cur_x = round(keypt_set[i][j].pt.x); if( cur_y < h && cur_y >= 0 && cur_x < w && cur_x >= 0) { int idx = cur_y*w + cur_x; if( pcl_isfinite(cloud_set[i]->at(idx).z) == true ) { keypt_cloud[i]->push_back(cloud_set[i]->at(idx)); mat_tmp.push_back(keydescr_set[i].row(j)); } } else std::cerr << cur_y << " " << cur_x << " " << h << " " << w << std::endl; } cv::vconcat(mat_tmp, key_active_set[i]); cloud_f_set[i] = FilterBoundary(cloud_set[i]); //std::cerr << keypt_cloud[i]->size() << "***" << key_active_set[i].rows << std::endl; } std::vector< Eigen::Matrix4f, Eigen::aligned_allocator<Eigen::Matrix4f> > tran_set(frame_num); tran_set[0] = Eigen::Matrix4f::Identity(); pcl::visualization::PCLVisualizer::Ptr viewer(new pcl::visualization::PCLVisualizer()); viewer->initCameraParameters(); viewer->addCoordinateSystem(0.1); viewer->setCameraPosition(0, 0, 0.1, 0, 0, 1, 0, -1, 0); pcl::registration::CorrespondenceRejectorSampleConsensus<PointT> crsc; crsc.setInlierThreshold( 0.005 ); crsc.setMaximumIterations( 2000 ); std::vector< pcl::PointCloud<PointT>::Ptr > tran_model_set(frame_num); pcl::PointCloud<PointT>::Ptr full_model(new pcl::PointCloud<PointT>()); pcl::copyPointCloud(*cloud_f_set[0], *full_model); tran_model_set[0] = cloud_f_set[0]; viewer->removePointCloud("full"); viewer->addPointCloud(full_model, "full"); viewer->spin(); for(int i = 1 ; i < frame_num ; i++ ) { std::cerr << "Frame --- " << i << std::endl; pcl::CorrespondencesPtr cur_corrs = matchSIFT(key_active_set[i], key_active_set[i-1]); crsc.setInputSource( keypt_cloud[i] ); crsc.setInputTarget( keypt_cloud[i-1] ); crsc.setInputCorrespondences( cur_corrs ); pcl::CorrespondencesPtr in_corr (new pcl::Correspondences()); crsc.getCorrespondences( *in_corr ); Eigen::Matrix4f init_guess = crsc.getBestTransformation(); init_guess = tran_set[i-1] * init_guess; tran_set[i] = DenseColorICP(cloud_f_set[i], tran_model_set[i-1], init_guess); pcl::PointCloud<PointT>::Ptr Final (new pcl::PointCloud<PointT>); pcl::transformPointCloud(*cloud_f_set[i], *Final, tran_set[i]); tran_model_set[i] = Final; full_model->insert(full_model->end(), Final->begin(), Final->end()); viewer->removePointCloud("full"); viewer->addPointCloud(full_model, "full"); viewer->spinOnce(1); } std::cerr << "Registration Done!!!" << std::endl; pcl::PointCloud<PointT>::Ptr down_model(new pcl::PointCloud<PointT>()); pcl::VoxelGrid<PointT> sor; sor.setInputCloud(full_model); sor.setLeafSize(0.001, 0.001, 0.001); sor.filter(*down_model); /* //* pcl::search::KdTree<PointT>::Ptr mls_tree (new pcl::search::KdTree<PointT>); pcl::MovingLeastSquares<PointT, PointT> mls; // Set parameters mls.setInputCloud (down_model); mls.setComputeNormals(false); mls.setPolynomialFit(true); mls.setSearchMethod (mls_tree); mls.setSearchRadius (0.01); // Reconstruct pcl::PointCloud<PointT>::Ptr down_model_f(new pcl::PointCloud<PointT>()); mls.process (*down_model_f); */ //std::cerr << "Smoothing Done!!!" << std::endl; //*/ //viewer->removePointCloud("full"); //viewer->addPointCloud(down_model_f, "down"); //viewer->spin(); return down_model; }
bool FDateTime::ParseIso8601( const TCHAR* DateTimeString, FDateTime& OutDateTime ) { // DateOnly: YYYY-MM-DD // DateTime: YYYY-mm-ddTHH:MM:SS(.ssss)(Z|+th:tm|-th:tm) const TCHAR* Ptr = DateTimeString; TCHAR* Next = nullptr; int32 Year = 0, Month = 0, Day = 0; int32 Hour = 0, Minute = 0, Second = 0, Millisecond = 0; int32 TzHour = 0, TzMinute = 0; // get date Year = FCString::Strtoi(Ptr, &Next, 10); if ((Next <= Ptr) || (*Next == TCHAR('\0'))) { return false; } Ptr = Next + 1; // skip separator Month = FCString::Strtoi(Ptr, &Next, 10); if ((Next <= Ptr) || (*Next == TCHAR('\0'))) { return false; } Ptr = Next + 1; // skip separator Day = FCString::Strtoi(Ptr, &Next, 10); if (Next <= Ptr) { return false; } // see if this is date+time if (*Next == TCHAR('T')) { Ptr = Next + 1; // parse time Hour = FCString::Strtoi(Ptr, &Next, 10); if ((Next <= Ptr) || (*Next == TCHAR('\0'))) { return false; } Ptr = Next + 1; // skip separator Minute = FCString::Strtoi(Ptr, &Next, 10); if ((Next <= Ptr) || (*Next == TCHAR('\0'))) { return false; } Ptr = Next + 1; // skip separator Second = FCString::Strtoi(Ptr, &Next, 10); if (Next <= Ptr) { return false; } // check for milliseconds if (*Next == TCHAR('.')) { Ptr = Next + 1; Millisecond = FCString::Strtoi(Ptr, &Next, 10); // should be no more than 3 digits if ((Next <= Ptr) || (Next > Ptr + 3)) { return false; } for (int32 Digits = Next - Ptr; Digits < 3; ++Digits) { Millisecond *= 10; } } // see if the timezone offset is included if (*Next == TCHAR('+') || *Next == TCHAR('-')) { // include the separator since it's + or - Ptr = Next; // parse the timezone offset TzHour = FCString::Strtoi(Ptr, &Next, 10); if ((Next <= Ptr) || (*Next == TCHAR('\0'))) { return false; } Ptr = Next + 1; // skip separator TzMinute = FCString::Strtoi(Ptr, &Next, 10); if (Next <= Ptr) { return false; } } else if ((*Next != TCHAR('\0')) && (*Next != TCHAR('Z'))) { return false; } } else if (*Next != TCHAR('\0')) { return false; } FDateTime Final(Year, Month, Day, Hour, Minute, Second, Millisecond); // adjust for the timezone (bringing the DateTime into UTC) int32 TzOffsetMinutes = (TzHour < 0) ? TzHour * 60 - TzMinute : TzHour * 60 + TzMinute; Final -= FTimespan(0, TzOffsetMinutes, 0); OutDateTime = Final; return true; }
int main (int argc, char** argv){ if(argc < 3) { std::cerr << "# computes transform to rotate a generic cube to a clustered cube " << std::endl; std::cerr << "# run with <inputcube..path> <outpath> <id>" << std::endl; return EXIT_FAILURE; } std::string filepath = std::string(argv[1]); std::string outpath = std::string(argv[2]); int id = atoi(argv[3]); std::cerr << "# processing: " << filepath << std::endl; std::cerr << "# outpath: " << outpath << std::endl; std::cerr << "# id: " << id << std::endl; //pcl::PointCloud<pcl::PointXYZ>::Ptr cloud = readBinfileCCS(filepath); pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>); pcl::PointCloud<pcl::PointXYZ>::Ptr cubeCloud; pcl::PointCloud<pcl::PointXYZ>::Ptr Final (new pcl::PointCloud<pcl::PointXYZ>); pcl::io::loadPCDFile(filepath, *cloud); std::cerr << "# read width: " << cloud->width; std::cerr << " height: " << cloud->height << std::endl; #ifdef DEBUG std::cerr << "# generating cubeCloud" << std::endl; #endif // low res cubeCloud = genTestCube(nShortSideLowRes,nLongSideLowRes); // gen our comparison cube // higher res //cubeCloud = genTestCube(nShortSideHighRes,nLongSideHighRes); // gen our comparison cube #ifdef DEBUG std::cerr << "# starting icp" << std::endl; #endif pcl::IterativeClosestPoint<pcl::PointXYZ, pcl::PointXYZ> icp; icp.setInputCloud(cubeCloud); icp.setInputTarget(cloud); icp.setTransformationEpsilon(1e-6); icp.setMaximumIterations(128); icp.setRANSACOutlierRejectionThreshold(0.01); //icp.setMaxCorrespondenceDistance(0.01); icp.align(*Final); #ifdef DEBUG std::cout << "has converged:" << icp.hasConverged() << " score: " << icp.getFitnessScore() << std::endl; std::cout << icp.getFinalTransformation() << std::endl; #endif std::stringstream ss; ss << "fitted_cube_" << id << ".pcd"; boost::filesystem::path outPath(outpath); // append the result string to the outpath correctly outPath /= ss.str(); std::cerr << "# filename: " << outPath << std::endl; //writeBinfileCCS(Final, outpath); pcl::io::savePCDFileASCII (outPath.native(), *Final); std::ofstream file; ss.clear(); ss.str(""); ss << "transformation_" << id << ".txt"; outPath.clear(); outPath /= outpath; outPath /= ss.str(); std::cerr << "# filename: " << outPath << std::endl; file.open(outPath.c_str()); file << icp.getFinalTransformation() << std::endl; file.close(); // append to the centroids file ss.clear(); ss.str(""); ss << "centroids_icp.dat"; outPath.clear(); outPath /= outpath; outPath /= ss.str(); file.open(outPath.c_str(), std::ios::app | std::ios::out); // get the transmat Eigen::Matrix4f transMat = icp.getFinalTransformation(); // write out the id, file << id; // the centroid (first 3 elts of final col) file << transMat(0, 3) << " " << transMat(1, 3) << " " << transMat(2,3); // the y rotation which should be (1,1) ? file << transMat(1,1) << std::endl; file.close(); return EXIT_SUCCESS; }
NFCGridModule::~NFCGridModule() { Final(); }
friend constexpr Final operator<<(Final const&x, IntegralType y) noexcept { return Final(typename Final::underlying_type(x.underlying() << y)); }
int main() { UINT32 x = 0; int i; { UINT32 state[50]; const UINT32 imageOfAllZero[50] = { 0xD33D89FB, 0xC4B60CAD, 0x2FAD58B0, 0x88AE581B, 0xF4262C1A, 0x8A53D3EF, 0x77B4B09B, 0xE0147822, 0x10A38DCF, 0xB6305181, 0xF723F2BE, 0xF9C67B78, 0x4EB02ABA, 0x8FCCC118, 0x2DC2E52E, 0xA3B29275, 0x342F5536, 0xE4DD320A, 0x45C7C3EA, 0x493D8BE4, 0x9C1717E7, 0xF3E75194, 0x12A23D11, 0xEDD52441, 0x13E6DBFF, 0x8C61BB03, 0x945B1B82, 0x1E4A11A5, 0x1C3453E7, 0x0D730C1B, 0x3B9C1D29, 0x0C534AF4, 0xA6EC29CC, 0x4FFDAA4D, 0x96C7DAA5, 0x45487850, 0x4ECFBC29, 0xE630383B, 0x26806B48, 0xA7EB2B5A, 0x62D02426, 0x8265F750, 0x49D20B1A, 0x20E4D82C, 0x6F72B2B8, 0x1C45D049, 0xFEA9F415, 0x4D0E74C7, 0x8DFDEA09, 0xFCF72ED2 }; // Test 1 (all-zero state through Keccak-f[1600]) memset(state, 0, 50*sizeof(UINT32)); KeccakPermutation((unsigned char*)state); for(i=0; i<50; i++) if (state[i] != imageOfAllZero[i]) for( ; ; ) { // Kaccek (aka other algo) x++; } // For benchmarking { #ifdef ProvideFast1024 KeccakAbsorb1024bits((unsigned char*)state, (unsigned char*)imageOfAllZero); #else KeccakAbsorb((unsigned char*)state, (unsigned char*)imageOfAllZero, 16); #endif } } { hashState state; const UINT8 Msg29[4] = { 0x53, 0x58, 0x7B, 0xC8 }; const UINT8 Msg29_out[160] = { 0xDE, 0xEB, 0xFB, 0x5F, 0xBC, 0x67, 0x14, 0x3A, 0x70, 0xF5, 0xEE, 0x51, 0x8F, 0x3C, 0xE2, 0x0A, 0x70, 0x2A, 0x3C, 0x25, 0x0C, 0x22, 0xD9, 0x39, 0xD7, 0xEE, 0xF5, 0x98, 0xA3, 0x9C, 0xA5, 0xC5, 0x37, 0x41, 0xB6, 0xF5, 0x7B, 0x58, 0x40, 0xAD, 0xD2, 0x8E, 0xF6, 0x14, 0x0A, 0xAD, 0x9D, 0x4C, 0x2B, 0x8E, 0xCC, 0x6A, 0x89, 0xFC, 0x5E, 0xFE, 0x73, 0x1F, 0x5E, 0x69, 0x7B, 0x83, 0xB8, 0x1C, 0x27, 0xED, 0xE0, 0xD2, 0x26, 0xBB, 0x30, 0xDE, 0x0A, 0x93, 0xF5, 0xCE, 0xDB, 0xC1, 0x6E, 0x32, 0xBA, 0x9D, 0x6B, 0x10, 0x48, 0x8A, 0x5A, 0x0E, 0x55, 0x5C, 0xB2, 0x96, 0x9F, 0x51, 0xE5, 0x8D, 0x46, 0xF0, 0x03, 0xF5, 0x0F, 0x9D, 0x84, 0x5A, 0xAF, 0x43, 0x07, 0x66, 0x76, 0x23, 0x82, 0xAD, 0xFD, 0x9B, 0x4C, 0xF0, 0x59, 0x16, 0xDF, 0xD6, 0x5C, 0x8A, 0x8C, 0xFC, 0xDE, 0xC5, 0xD0, 0x45, 0x34, 0x07, 0x38, 0x7D, 0xBC, 0xF3, 0xA7, 0x44, 0x26, 0x8E, 0x85, 0xB3, 0x5B, 0x50, 0x0E, 0xDD, 0x1E, 0xD5, 0x09, 0x01, 0x55, 0xA6, 0x35, 0xBF, 0xA4, 0x6A, 0xC2, 0x4D, 0xA7, 0x98, 0xE8, 0x24 }; UINT8 output[160]; // Test 2 (message of length 29 from ShortMsgKAT_0.txt) Init(&state, 0); Update(&state, Msg29, 29); Final(&state, 0); Squeeze(&state, output, 160*8); for(i=0; i<160; i++) if (output[i] != Msg29_out[i]) for( ; ; ) { // Kaccek (aka other algo) x++; } } for ( ; ; ) ; }
int main( void ) { unsigned long long inlen; unsigned long long offset; unsigned long long size; int result = 0; FILE *fp_in; char marker[20]; int refLen; hashState state; #ifdef cKeccakFixedOutputLengthInBytes refLen = cKeccakFixedOutputLengthInBytes; #else refLen = cKeccakR_SizeInBytes; #endif printf( "Testing Keccak[r=%u, c=%u] using crypto_hash() against %s over %d squeezed bytes\n", cKeccakR, cKeccakB - cKeccakR, testVectorFile, refLen ); if ( (fp_in = fopen(testVectorFile, "r")) == NULL ) { printf("Couldn't open <%s> for read\n", testVectorFile); return 1; } for ( inlen = 0; inlen <= cKeccakMaxMessageSizeInBytes; ++inlen ) { sprintf( marker, "Len = %u", inlen * 8 ); if ( !FindMarker(fp_in, marker) ) { printf("ERROR: no test vector found (%u bytes)\n", inlen ); result = 1; break; } if ( !ReadHex(fp_in, input, (int)inlen, "Msg = ") ) { printf("ERROR: unable to read 'Msg' (%u bytes)\n", inlen ); result = 1; break; } result = crypto_hash( output, input, inlen ); if ( result != 0 ) { printf("ERROR: crypto_hash() (%u bytes)\n", inlen); result = 1; break; } #ifdef cKeccakFixedOutputLengthInBytes if ( !ReadHex(fp_in, input, refLen, "MD = ") ) #else if ( !ReadHex(fp_in, input, refLen, "Squeezed = ") ) #endif { printf("ERROR: unable to read 'Squeezed/MD' (%u bytes)\n", inlen ); result = 1; break; } if ( memcmp( output, input, refLen ) != 0) { printf("ERROR: hash verification (%u bytes)\n", inlen ); for(result=0; result<refLen; result++) printf("%02X ", output[result]); printf("\n"); result = 1; break; } } if ( !result ) printf( "\nSuccess!\n"); result = 0; refLen = cKeccakHashRefSizeInBytes; printf( "\nTesting Keccak[r=%u, c=%u] using Init/Update/Final() against %s over %d squeezed bytes\n", cKeccakR, cKeccakB - cKeccakR, testVectorFile, refLen ); fseek( fp_in, 0, SEEK_SET ); for ( inlen = 0; inlen <= cKeccakMaxMessageSizeInBits; ++inlen ) { sprintf( marker, "Len = %u", inlen ); if ( !FindMarker(fp_in, marker) ) { printf("ERROR: no test vector found (%u bits)\n", inlen ); result = 1; break; } if ( !ReadHex(fp_in, input, (int)inlen, "Msg = ") ) { printf("ERROR: unable to read 'Msg' (%u bits)\n", inlen ); result = 1; break; } result = Init( &state ); if ( result != 0 ) { printf("ERROR: Init() (%u bits)\n", inlen); result = 1; break; } for ( offset = 0; offset < inlen; offset += size ) { // vary sizes for Update() if ( (inlen %8) < 2 ) { // byte per byte size = 8; } else if ( (inlen %8) < 4 ) { // incremental size = offset + 8; } else { // random size = ((rand() % ((inlen + 8) / 8)) + 1) * 8; } if ( size > (inlen - offset) ) { size = inlen - offset; } //printf("Update() inlen %u, size %u, offset %u\n", (unsigned int)inlen, (unsigned int)size, (unsigned int)offset ); result = Update( &state, input + offset / 8, size ); if ( result != 0 ) { printf("ERROR: Update() (%u bits)\n", inlen); result = 1; break; } } result = Final( &state, output, refLen ); if ( result != 0 ) { printf("ERROR: Final() (%u bits)\n", inlen); result = 1; break; } #ifdef cKeccakFixedOutputLengthInBytes if ( !ReadHex(fp_in, input, refLen, "MD = ") ) #else if ( !ReadHex(fp_in, input, refLen, "Squeezed = ") ) #endif { printf("ERROR: unable to read 'Squeezed/MD' (%u bits)\n", inlen ); result = 1; break; } if ( memcmp( output, input, refLen ) != 0) { printf("ERROR: hash verification (%u bits)\n", inlen ); for(result=0; result<refLen; result++) printf("%02X ", output[result]); printf("\n"); result = 1; break; } } fclose( fp_in ); if ( !result ) printf( "\nSuccess!\n"); //printf( "\nPress a key ..."); //getchar(); //printf( "\n"); return ( result ); }