{"id":20205355,"url":"https://github.com/cgxeiji/picam","last_synced_at":"2026-05-13T09:01:58.166Z","repository":{"id":57537951,"uuid":"286403247","full_name":"cgxeiji/picam","owner":"cgxeiji","description":"Go library for getting the last frame from a pi-camera on a Raspberry Pi","archived":false,"fork":false,"pushed_at":"2020-08-11T03:40:45.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-01T08:57:05.786Z","etag":null,"topics":["frame","go","golang","pi-camera","picam","raspberry-pi"],"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/cgxeiji.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}},"created_at":"2020-08-10T07:12:37.000Z","updated_at":"2022-03-13T05:10:04.000Z","dependencies_parsed_at":"2022-09-07T17:35:26.412Z","dependency_job_id":null,"html_url":"https://github.com/cgxeiji/picam","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cgxeiji/picam","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgxeiji%2Fpicam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgxeiji%2Fpicam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgxeiji%2Fpicam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgxeiji%2Fpicam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cgxeiji","download_url":"https://codeload.github.com/cgxeiji/picam/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgxeiji%2Fpicam/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32975183,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T06:31:55.726Z","status":"ssl_error","status_checked_at":"2026-05-13T06:31:51.336Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["frame","go","golang","pi-camera","picam","raspberry-pi"],"created_at":"2024-11-14T05:17:06.815Z","updated_at":"2026-05-13T09:01:58.130Z","avatar_url":"https://github.com/cgxeiji.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PiCam\n\n[![Version](https://img.shields.io/github/v/tag/cgxeiji/picam?sort=semver)](https://github.com/cgxeiji/picam/releases)\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/cgxeiji/picam)](https://pkg.go.dev/github.com/cgxeiji/picam)\n[![License](https://img.shields.io/github/license/cgxeiji/picam)](https://github.com/cgxeiji/picam/blob/master/LICENSE)\n![Go version](https://img.shields.io/github/go-mod/go-version/cgxeiji/picam)\n\n\nPiCam is a Go wrapper to `raspiyuv` to get `[]uint8` and `image.Image` data of\nthe latests frame captured by the Raspberry Pi camera.\n\nUnder the hood, it executes:\n```\n$ raspiyuv --timeout 0 --timelapse 0\n```\nto get raw frames.\n\nCurrently, three image formats are available:\n* picam.YUV\n* picam.RGB\n* picam.Gray\n\nThe time between frames, measured on a Raspberry Pi Zero W, is between `180ms` to\n`210ms` for a `640x480` pixels image.\n\nIf you want to test the speed in your system, run:\n```\n$ cd $(go env GOPATH)/src/github.com/cgxeiji/picam\n$ go test -bench . -benchtime=10x\n```\n\nThis will take 10 frames and output the average time between each frame. Change\n`-benchtime=10x` to `100x` or `Nx` to change the number of frames to test.\n\n\n## Why this library?\n\nI wanted to avoid the dependency on GoCV to access the camera on a Raspberry\nPi to do real-time face detection.\n\n## Example code\n\n```go\npackage main\n\nimport (\n\t\"image/png\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/cgxeiji/picam\"\n)\n\nfunc main() {\n\tcam, err := picam.New(640, 480, picam.YUV)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer cam.Close()\n\n\timg := cam.Read()\n\n\tf, err := os.Create(\"./image.png\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer f.Close()\n\n\terr = png.Encode(f, img)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n```\n\n## Example real-time face detection\n\nUsing the [pigo](https://github.com/esimov/pigo) libray from esimov, it is\npossible to do real-time face detection on a Raspberry Pi without depending on\nOpenCV.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\n\t\"github.com/cgxeiji/picam\"\n\tpigo \"github.com/esimov/pigo/core\"\n)\n\nfunc main() {\n\tcam, err := picam.New(640, 480, picam.Gray)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer cam.Close()\n\n\tcParams := pigo.CascadeParams{\n\t\tMinSize:     90,\n\t\tMaxSize:     200,\n\t\tShiftFactor: 0.1,\n\t\tScaleFactor: 1.1,\n\t\tImageParams: pigo.ImageParams{\n\t\t\tRows: cam.Height,\n\t\t\tCols: cam.Width,\n\t\t\tDim:  cam.Width,\n\t\t},\n\t}\n\n\tclassifierFile, err := ioutil.ReadFile(\"./facefinder\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tp := pigo.NewPigo()\n\tclassifier, err := p.Unpack(classifierFile)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfmt.Println(\"Starting face detection\")\n\tfmt.Println(\"Press Ctrl+C to stop\")\n\tfor {\n\t\tcParams.Pixels = cam.ReadUint8()\n\t\tfaces := classifier.RunCascade(cParams, 0.0) // 0.0 is the angle\n\t\tfaces = classifier.ClusterDetections(faces, 0.1)\n\n\t\t// Get the face with the highest confidence level\n\t\tvar maxQ float32\n\t\tindex := 0\n\t\tfor i, face := range faces {\n\t\t\tif face.Q \u003e maxQ {\n\t\t\t\tmaxQ = face.Q\n\t\t\t\tindex = i\n\t\t\t}\n\t\t}\n\n\t\tface := pigo.Detection{}\n\t\tif index \u003c len(faces) {\n\t\t\tface = faces[index]\n\t\t}\n\n\t\tif face.Scale == 0 {\n\t\t\t// no face detected\n\t\t\tfmt.Printf(\"\\rno face detected                                                 \")\n\t\t\tcontinue\n\t\t}\n\n\t\tx := face.Col - cam.Width/2\n\t\ty := -face.Row + cam.Height/2 // y is flipped\n\n\t\tfmt.Printf(\"\\rface is (%d, %d) pixels from the center\", x, y)\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcgxeiji%2Fpicam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcgxeiji%2Fpicam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcgxeiji%2Fpicam/lists"}