{"id":17968316,"url":"https://github.com/travisbrown/rotation-rs","last_synced_at":"2025-03-25T09:30:43.916Z","repository":{"id":38332258,"uuid":"275416967","full_name":"travisbrown/rotation-rs","owner":"travisbrown","description":"Document rotation detection","archived":false,"fork":false,"pushed_at":"2023-01-20T22:42:03.000Z","size":2253,"stargazers_count":7,"open_issues_count":22,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-20T00:38:21.710Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/travisbrown.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-06-27T17:04:06.000Z","updated_at":"2022-12-20T14:52:10.000Z","dependencies_parsed_at":"2023-02-12T06:16:30.410Z","dependency_job_id":null,"html_url":"https://github.com/travisbrown/rotation-rs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travisbrown%2Frotation-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travisbrown%2Frotation-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travisbrown%2Frotation-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travisbrown%2Frotation-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/travisbrown","download_url":"https://codeload.github.com/travisbrown/rotation-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245435029,"owners_count":20614816,"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":[],"created_at":"2024-10-29T14:20:58.105Z","updated_at":"2025-03-25T09:30:43.911Z","avatar_url":"https://github.com/travisbrown.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Document rotation detection\n\nThis is my first attempt at compiling Rust to [WebAssembly](https://webassembly.org/).\nIt's a Saturday project and probably won't go anywhere or be maintained in any way. I know nothing\nabout WebAssembly and very little about Rust, so it's unlikely to illustrate best practices.\n\nThe application is an OCR preprocessor that takes a scanned document (which may be rotated) and\nattempts to estimate the angle of rotation. It does this by computing the Fourier transform of the\nimage using [RustFFT](https://github.com/awelkie/RustFFT).\nIf this was real code it'd probably be better to use\n[Rust's OpenCV bindings](https://github.com/twistedfall/opencv-rust),\nbut I had to stick to pure Rust libraries since the goal was to run this in the browser via\nWebAssembly.\n\nThe code includes ideas from [here](https://stackoverflow.com/a/33707537/334519) and\n[here](https://blog.stackpath.com/image-manipulation/), as well as the official Rust documentation.\n\nIf you have Rust, Cargo, and npm installed and you've run `cargo install wasm-pack` at some point,\nyou should be able to build the web application like this:\n\n```bash\n$ wasm-pack build\n$ cd www/\n$ npm install\n$ npm run start\n```\n\nThe application should then be available at [localhost:8080](http://localhost:8080/):\n\n![Web application](https://github.com/travisbrown/rotation-rs/blob/main/examples/screenshot-01.png?raw=true)\n\nYou can also build a native CLI, which you can test against synthetic data like this\n(if you have [ImageMagick](https://imagemagick.org/) installed):\n\n```bash\n$ cargo build --release\n$ convert -rotate 5 examples/lorem.png lorem-5.png\n$ target/release/rotation lorem-5.png\n5.0040045\n$ convert -rotate 7.5 examples/lorem.png lorem-7.5.png\n$ target/release/rotation lorem-7.5.png\n7.487998\n$ convert -rotate -1.8 examples/lorem.png lorem-1.8.png\n$ target/release/rotation lorem-1.8.png\n-1.746\n```\n\nIt's not great, but it's not terrible for a few dozen lines of code.\n\nThe CLI can also save the FFT spectrum as an image:\n\n```bash\ntarget/release/rotation --output examples/fft.png lorem-7.5.png\n```\n\nWhich looks like this:\n\n![FFT spectrum](https://github.com/travisbrown/rotation-rs/blob/main/examples/fft.png?raw=true)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftravisbrown%2Frotation-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftravisbrown%2Frotation-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftravisbrown%2Frotation-rs/lists"}