static void load_amd_features(struct cpu_raw_data_t* raw, struct cpu_id_t* data) { const struct feature_map_t matchtable_edx81[] = { { 20, CPU_FEATURE_NX }, { 22, CPU_FEATURE_MMXEXT }, { 25, CPU_FEATURE_FXSR_OPT }, { 30, CPU_FEATURE_3DNOWEXT }, { 31, CPU_FEATURE_3DNOW }, }; const struct feature_map_t matchtable_ecx81[] = { { 1, CPU_FEATURE_CMP_LEGACY }, { 2, CPU_FEATURE_SVM }, { 5, CPU_FEATURE_ABM }, { 6, CPU_FEATURE_SSE4A }, { 7, CPU_FEATURE_MISALIGNSSE }, { 8, CPU_FEATURE_3DNOWPREFETCH }, { 9, CPU_FEATURE_OSVW }, { 10, CPU_FEATURE_IBS }, { 11, CPU_FEATURE_XOP }, { 12, CPU_FEATURE_SKINIT }, { 13, CPU_FEATURE_WDT }, { 16, CPU_FEATURE_FMA4 }, { 21, CPU_FEATURE_TBM }, }; const struct feature_map_t matchtable_edx87[] = { { 0, CPU_FEATURE_TS }, { 1, CPU_FEATURE_FID }, { 2, CPU_FEATURE_VID }, { 3, CPU_FEATURE_TTP }, { 4, CPU_FEATURE_TM_AMD }, { 5, CPU_FEATURE_STC }, { 6, CPU_FEATURE_100MHZSTEPS }, { 7, CPU_FEATURE_HWPSTATE }, /* id 8 is handled in common */ { 9, CPU_FEATURE_CPB }, { 10, CPU_FEATURE_APERFMPERF }, { 11, CPU_FEATURE_PFI }, { 12, CPU_FEATURE_PA }, }; if (raw->ext_cpuid[0][0] >= 0x80000001) { match_features(matchtable_edx81, COUNT_OF(matchtable_edx81), raw->ext_cpuid[1][3], data); match_features(matchtable_ecx81, COUNT_OF(matchtable_ecx81), raw->ext_cpuid[1][2], data); } if (raw->ext_cpuid[0][0] >= 0x80000007) match_features(matchtable_edx87, COUNT_OF(matchtable_edx87), raw->ext_cpuid[7][3], data); if (raw->ext_cpuid[0][0] >= 0x8000001a) { /* We have the extended info about SSE unit size */ data->detection_hints[CPU_HINT_SSE_SIZE_AUTH] = 1; data->sse_size = (raw->ext_cpuid[0x1a][0] & 1) ? 128 : 64; } }
int main() { Mat imgL = imread("aloeL.jpg", IMREAD_GRAYSCALE); Mat imgR = imread("aloeR.jpg", IMREAD_GRAYSCALE); if(imgL.empty() || imgR.empty()){ cout << "read image error "<< endl; return 0 ; } // double threshold_value = 0.0001; // harris_detection(image,threshold_value); // int minHessian = 80; // sift_detection(image,minHessian); // akaze_detection(image); vector<string> image_names = {"aloeL.jpg","aloeR.jpg"}; vector<vector<KeyPoint>> key_points_for_all; vector<Mat> descriptor_for_all; vector<vector<Vec3b>> colors_for_all; Mat query; Mat train; vector<DMatch> matches; extract_features( image_names,key_points_for_all,descriptor_for_all, colors_for_all); match_features(query, train, matches); find_transform(Mat& K, vector<Point2f>& p1, vector<Point2f>& p2, Mat& R, Mat& T, Mat& mask); reconstruct(Mat& K, Mat& R, Mat& T, vector<Point2f>& p1, vector<Point2f>& p2, Mat& structure); return 0; }
void make_tet_mesh(TetMesh& mesh, const SDF& sdf, FeatureSet& featureSet, bool optimize, bool intermediate, bool unsafe) { // Initialize exact arithmetic initialize_exact(); // Initialize mesh from acute lattice. std::vector<float> vphi; // SDF value at each lattice vertex. mesh.verts().resize(0); mesh.tets().resize(0); std::cout<<" cutting from lattice"<<std::endl; cut_lattice(sdf, mesh, vphi); if (intermediate) { static const char* cutLatticeFile = "1_cut_lattice.tet"; static const char* cutLatticeInfo = "1_cut_lattice.info"; mesh.writeToFile(cutLatticeFile); mesh.writeInfoToFile(cutLatticeInfo); std::cout << "Mesh written to " << cutLatticeFile << std::endl; } // Warp any vertices close enough to phi=0 to fix sign crossings. static const float WARP_THRESHOLD = 0.3; std::cout<<" warping vertices"<<std::endl; warp_vertices(WARP_THRESHOLD, mesh, vphi); if (intermediate) { static const char* warpVerticesFile = "2_warp_vertices.tet"; static const char* warpVerticesInfo = "2_warp_vertices.info"; mesh.writeToFile(warpVerticesFile); mesh.writeInfoToFile(warpVerticesInfo); std::cout << "Mesh written to " << warpVerticesFile << std::endl; } // Cut through tets that still poke out of the level set std::cout<<" trimming spikes"<<std::endl; trim_spikes(mesh, vphi); if (intermediate) { static const char* trimSpikesFile = "3_trim_spikes.tet"; static const char* trimSpikesInfo = "3_trim_spikes.info"; mesh.writeToFile(trimSpikesFile); mesh.writeInfoToFile(trimSpikesInfo); std::cout << "Mesh written to " << trimSpikesFile << std::endl; } // At this point, there could be some bad tets with all four vertices on // the surface but which lie outside the level set. Get rid of them. std::cout<<" removing exterior tets"<<std::endl; remove_exterior_tets(mesh, vphi, sdf); // Compact mesh and clear away unused vertices. std::cout<<" compacting mesh"<<std::endl; mesh.compactMesh(); if (intermediate) { static const char* removeExtFile = "4_remove_exterior.tet"; static const char* removeExtInfo = "4_remove_exterior.info"; static const char* removeExtObj = "4_remove_exterior.obj"; mesh.writeToFile(removeExtFile); mesh.writeInfoToFile(removeExtInfo); std::vector<Vec3f> objVerts; std::vector<Vec3i> objTris; mesh.getBoundary(objVerts, objTris); write_objfile(objVerts, objTris, removeExtObj); std::cout << "Mesh written to " << removeExtFile << std::endl; } // Compute maximum dihedral angle of mesh (unoptimized, no features). std::cout << " Maximum dihedral angle = " << max_dihedral_angle(mesh) << std::endl; if (featureSet.numFeatures() > 0 || optimize) { // Identify boundary vertices std::vector<int> boundary_verts; std::vector<Vec3i> boundary_tris; std::cout << " identifying boundary" << std::endl; mesh.getBoundary(boundary_verts, boundary_tris); assert(!boundary_verts.empty()); // Snap vertices to given features std::vector<int> feature_endpoints; std::map<int, int> vertex_feature_map; if (featureSet.numFeatures() > 0) { // Move vertices to match desired features std::cout << " matching features" << std::endl; clock_t featureTime = clock(); match_features(mesh, featureSet, sdf.dx, boundary_verts, boundary_tris, feature_endpoints, vertex_feature_map, unsafe); featureTime = clock() - featureTime; std::cout << " features matched in " << ((float)featureTime)/CLOCKS_PER_SEC << " seconds." << std::endl; std::cout << " Maximum dihedral angle = " << max_dihedral_angle(mesh) << std::endl; if (optimize && intermediate) { static const char* matchFeaturesFile = "5_match_features.tet"; static const char* matchFeaturesInfo = "5_match_features.info"; mesh.writeToFile(matchFeaturesFile); mesh.writeInfoToFile(matchFeaturesInfo); std::cout << "Mesh written to " << matchFeaturesFile << std::endl; } } // Finish by optimizing the tetmesh, if desired. if (optimize) { std::cout << " optimizing mesh" << std::endl; clock_t optTime = clock(); optimize_tet_mesh(mesh, sdf, boundary_verts, featureSet, feature_endpoints, vertex_feature_map); optTime = clock() - optTime; std::cout << " Mesh optimization completed in " << ((float)optTime)/CLOCKS_PER_SEC << " seconds." << std::endl; std::cout<< " Maximum dihedral angle = " << max_dihedral_angle(mesh) << std::endl; } // DEBUGGING // Check for inverted tets for (size_t t = 0; t < mesh.tSize(); ++t) { Tet tet = mesh.getTet(t); float signedVolume = tet.volume(); if (signedVolume <= 0.0) { std::cerr << "Tet #" << t << " is inverted! " << "Volume = " << signedVolume << "; " << "Aspect = " << tet.aspectRatio() << std::endl << "{" << tet[0] << "} {" << tet[1] << "} {" << tet[2] << "} {" << tet[3] << "}" << std::endl; } } } }