This repo contains the source code for a web application that can count fruit seeds.
To use:
- Place some seeds on a sheet of white (printer) paper. Leave some space at the page's borders (don't place seeds right up to the edges)
- For best results, try to have the seeds separated from each other (i.e. no clumps)
- Obtain a smartphone or tablet (i.e. some device that can run a web browser such as Chrome, and has a back-facing camera). Android preferred
- Click the DEMO button above on the device to navigate to the app, or go to https://seedcount.jreyesr.com/
- If prompted, allow the application to access the device's camera
- You should see a feed from the device's back-facing camera
- Move the device so the camera sees the entire page filled with seeds, and nothing else
- Press the red button to capture an image
- A few seconds later, you'll get an image to the right of the live feed, which contains the identified seeds
The app uses OpenCV.js, which allows it to perform image processing operations entirely client-side (traditionally OpenCV requires a Python or C++ backend).
The exact algorithms used are documented in great detail in a blog post.
cd backend
npx wrangler deploy
This will compile, bundle and upload the backend/src/index.ts
to Cloudflare Workers, thus deploying a new version of the backend.
npx workbox-cli injectManifest workbox-config.js
This will update the "revision" (i.e. hash) of index.html
for the Service Worker,
so it can cache-bust the HTML file. It will write the final SW file
to sw.out.js
, which is the file that is actually registered on the browser.