{"id":21411784,"url":"https://github.com/elicdavis/sfm","last_synced_at":"2026-03-10T18:05:13.675Z","repository":{"id":216412339,"uuid":"741271066","full_name":"EliCDavis/sfm","owner":"EliCDavis","description":"Utilities for interacting with SFM Data in golang","archived":false,"fork":false,"pushed_at":"2024-05-11T15:19:55.000Z","size":10,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-06-21T20:09:49.501Z","etag":null,"topics":["colmap","meshroom","opensfm","photogrammetry","sfm"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EliCDavis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-10T03:38:33.000Z","updated_at":"2024-05-11T15:19:58.000Z","dependencies_parsed_at":"2024-05-11T16:31:11.397Z","dependency_job_id":null,"html_url":"https://github.com/EliCDavis/sfm","commit_stats":null,"previous_names":["elicdavis/sfm"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EliCDavis%2Fsfm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EliCDavis%2Fsfm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EliCDavis%2Fsfm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EliCDavis%2Fsfm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EliCDavis","download_url":"https://codeload.github.com/EliCDavis/sfm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225941813,"owners_count":17549070,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["colmap","meshroom","opensfm","photogrammetry","sfm"],"created_at":"2024-11-22T17:47:33.619Z","updated_at":"2026-03-10T18:05:08.630Z","avatar_url":"https://github.com/EliCDavis.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SFM\n\nStructs for interacting with reconstruction data from different SFM programs\n\n* COLMAP\n\t* Cameras\n\t* Points\n\t* Images\n\t* Depthmap\n\t* Normalmap\n* OpenSFM\n\t* reconstruction.json\n* Meshroom\n\t* cameras.sfm\n\n## COLMAP\n\n### Point Data\n\nInteract with COLMAPS's `points3D.bin` file output under the sparse reconstruction data.\n\n```golang\npackage example\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/EliCDavis/sfm/colmap\"\n)\n\nfunc main() {\n\tpoints, err := colmap.LoadPoints3DBinary(\"ColmapProject/sparse/0/points3D.bin\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Printf(\"File contains %d points\", len(points))\n}\n```\n\n### Cameras\n\nInteract with COLMAPS's `cameras.bin` file output under the sparse reconstruction data.\n\n```golang\npackage example\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/EliCDavis/sfm/colmap\"\n)\n\nfunc main() {\n\tcameras, err := colmap.LoadCamerasBinary(\"ColmapProject/sparse/0/cameras.bin\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Printf(\"File contains %d cameras\", len(cameras))\n}\n```\n\n### Images\n\nInteract with COLMAPS's `images.bin` file output under the sparse reconstruction data.\n\n```golang\npackage example\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/EliCDavis/sfm/colmap\"\n)\n\nfunc main() {\n\timages, err := colmap.LoadImagesBinary(\"ColmapProject/sparse/0/images.bin\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Printf(\"File contains %d images\", len(images))\n}\n```\n\n### Depth maps\n\nCreate a Image representing the depthmap data\n\n```golang\npackage main\n\nimport (\n\t\"image\"\n\t\"image/color\"\n\t\"image/png\"\n\t\"os\"\n\t\"testing\"\n\n\t\"github.com/EliCDavis/sfm/colmap\"\n)\n\nfunc check(err error) {\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc main() {\n\tdepthmap, err := colmap.LoadDepthmap(\"depthmap.bin\")\n\tcheck(err)\n\n\tmaxV := depthmap.MaxValue()\n\timg := image.NewRGBA(image.Rect(0, 0, depthmap.Width, depthmap.Height))\n\tfor x := 0; x \u003c depthmap.Width; x++ {\n\t\tfor y := 0; y \u003c depthmap.Height; y++ {\n\t\t\tv := byte(min((depthmap.Value(x, y)/maxV), 1) * 255)\n\t\t\timg.Set(x, y, color.RGBA{\n\t\t\t\tR: v,\n\t\t\t\tG: v,\n\t\t\t\tB: v,\n\t\t\t\tA: 255,\n\t\t\t})\n\t\t}\n\t}\n\n\tf, err := os.Create(\"depth.png\")\n\tcheck(err)\n\tdefer f.Close()\n\tcheck(png.Encode(f, img))\n}\n```\n\n### Normal maps\n\nCreate a Image representing the normalmap data\n\n\n```golang\npackage main\n\nimport (\n\t\"bufio\"\n\t\"image\"\n\t\"image/color\"\n\t\"image/png\"\n\t\"os\"\n\t\"testing\"\n\n\t\"github.com/EliCDavis/sfm/colmap\"\n)\n\nfunc check(err error) {\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc main() {\n\tnormalMap, err := colmap.LoadNormalmap(\"normal.bin\")\n\tcheck(err)\n\n\timg := image.NewRGBA(image.Rect(0, 0, normalMap.Width, normalMap.Height))\n\tfor x := 0; x \u003c normalMap.Width; x++ {\n\t\tfor y := 0; y \u003c normalMap.Height; y++ {\n\t\t\tv := normalMap.Value(x, y)\n\n\t\t\t// https://github.com/colmap/colmap/blob/e924f0f825c6033a0cf2b89fa79c585236d4bf3a/src/colmap/mvs/normal_map.cc#L112\n\t\t\timg.Set(x, y, color.RGBA{\n\t\t\t\tR: uint8((v.X() + 1) * 0.5 * 255),\n\t\t\t\tG: uint8((v.Y() + 1) * 0.5 * 255),\n\t\t\t\tB: uint8(v.Z() * -255.),\n\t\t\t\tA: 255,\n\t\t\t})\n\t\t}\n\t}\n\n\tf, err := os.Create(\"normals.png\")\n\tcheck(err)\n\tdefer f.Close()\n\twriter := bufio.NewWriter(f)\n\tcheck(png.Encode(writer, img))\n\tcheck(writer.Flush())\n}\n```\n\n## Meshroom\n\nInteract with Meshroom's `cameras.sfm` file output from the `StructureFromMotion` step.\n\n```golang\npackage example\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/EliCDavis/sfm/meshroom\"\n)\n\nfunc main() {\n\tcameras, err := meshroom.LoadCameras(\"MeshroomProject/MeshroomCache/StructureFromMotion/abc123/cameras.sfm\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Printf(\"File contains %d Poses\", len(cameras.Poses))\n}\n```\n\n## OpenSFM\n\nInteract with OpenSFM's `reconstruction.json` file output from the `reconstruct` step.\n\n```golang\npackage example\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/EliCDavis/sfm/opensfm\"\n)\n\nfunc main() {\n\treconstructions, err := opensfm.LoadReconstruction(\"MyOpenSFMProject/reconstruction.json\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Printf(\"File contains %d reconstructions\", len(reconstructions))\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felicdavis%2Fsfm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felicdavis%2Fsfm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felicdavis%2Fsfm/lists"}