DIY Camera Using Raspberry Pi
ruha.camera
ruha.camera
The idea is to have the camera with a wide angle lens attached to the top of stack of papers/notebook. Pressing a button takes a picture, and then does a affine transform (?) on it get the perspective right, then uploads it to the LMS.
Just a clean, hassle free experience. No orienting your phone awkwardly, no getting the lighting right, no mini edits on your phone, no compiling pdfs.
Also, very useful for me, as I like to do math by hand.
Edit: Image https://imgur.com/Fb45H7M.png The fact that camera is fixed relative to paper means the transform is also fixed. Multi-colored led (and knowledge of paper color) can also fix lighting.
Plus with this, I could look at student solutions much easier during class or office hours.
Similarly, I don't want to whip out my phone to take 30 pictures of my research notes one by one.
This, to me, means I can never trust it for scanning sensitive or private documents, because who knows what it's sending. I declined to install it. YMMV.
Not to mention-- Firebase tracks what, events? You think somehow it's encoding the documents in an event stream to exfiltrate them?
You're complaining about a -disclosed- use of analytics.
It seems like you'd be happier with an app that just didn't mention the use.
It's neither silent nor without consent since you were told about it.
https://github.com/allgood/OpenNoteScanner
https://f-droid.org/en/packages/com.todobom.opennotescanner/
https://play.google.com/store/apps/details?id=com.todobom.op...
Seriously, though, I have idea. We can take two pictures focusing once the near part, and once on the far part.
If cameras are cheap (I haven't researched), maybe two on either end of the device would mitigate the complexity of the lenses required.
For example, this 1.8mm F/2.8 low distortion lens has a hyperfocal distance of 0.2m (~8") on the Pi HQ: https://commonlands.com/products/low-distortion-m12-lens and easily covers 6"-25" depth of field.
As we are working with standard paper, we know its color (as it appears to the camera in neutral light). We could have a calibration step, where the multicolored LEDs are tuned to get the right contrast and color balance. Though, I have no idea how well it will work in practice.
You could also just use the corners to compute the homograph transform.
Really depends on the constraints too. If you're going for archival quality scans then maybe it would be better to do it with hardware. At that point I'd just get a way higher res camera than needed, transform and down sample as needed. Would still probably be cheaper than a gimbal.
I've seen models that also have LED strips for even lighting. What I haven't seen is a gadget that can feed multiple sheets easily.
Auto scanning with border and angle detection works decently well [0], mini tripods with phone brackets abound. It’s very easy to set a phone above the table at a slight angle (that makes it easier to move the docs in and out and get rid of shadows) with the app auto scanning every sheet that’s laid below.
[0] I used Scanner Pro by Readle, on iOS for reference
Come to think of it a frame with a black base and an overhead light incorporating a phone holder would likely do the trick well.
And this seems more of a 'on my desk at home' sort of problem space than a 'whip it out of my bag' sort.
I think there is something to say about the sheer money size of the iOS ecosystem that allowed talented devs to get a decent ROI, even on niche apps.
I am happy with an android phone, but only because I also keep other iOS devices around for when I really miss some apps. And it seems a lot of people are on the same boat, looking at iOS apps as unitaskers that they'll chain and shoehorn into workflows that fit their needs, more than as "just works" magic tools.
I've changed my whole process now so it's not nearly as critical a step as it once was. But I still use it in passing.
Too bad it then simply adds as an attachment to the note and doesn't allow you to go straight to Share.
These days I just use the regular camera app. Documents are plenty readable as-is, and you can straighten/adjust 3D perspective/raise contrast using the regular photo editing features (at least in iOS)
But wait! You can use the press and hold (3D touch / force touch?) to skip no steps! 1. Click Save in bottom right (segues to note) 2. Click and hold the scan in note (3d touch pop up) 3. Click share in the pop up (open share menu) 4. Click method of share for pdf (sms, email, copy)
https://old.reddit.com/r/tasker/comments/aqyzbu/help_task_th...
You could use foldersync for that too.
Actions:
- start app
- take picture for every page and confirm
- save to gallery in the end. It will store to Pictures/Office lens
The task will automatically upload the files.
I've got a growing backlog of documents to scan. So... I've decided to make it a project and am building my own scanner control app [i] (using python) to help get them scanned (via ADF-doc feeder) and into my paperless-ng repository more easily (e.g. use QR codes to separate documents automatically and OCR to help pre-tag them before uploading).
This same setup could easily be mounted at a different angle for scanning papers laid flat on a desk, and would work with nearly no modification.
The image processing pipeline for me was:
- Gaussian blur
- Brightness/color thresholding
- Finding and simplifying the contours
- Computing the convex hull for each contour (in case the board is partially occluded)
- Using a heuristic to pick the contour most likely to be the chalkboard
- Extracting corners from the contour and doing a "getPerspectiveTransform" followed by "warpPerspective"
- Sharpen the image (subtract Gaussian blurred version)
- Return the image via Flask server so I can pull scans onto my phone or computer over LAN
The same pipeline is reused for a live feed (MJPEG) that I can split-screen with my webcam (via OBS) for collaboratively working on homework problems via video call. The live stream is accessed via a different Flask route that calls many of the same helper functions.The code is not yet publicly released, but was very straightforward to write; each of the steps mentioned above is pretty much one OpenCV function call. Here is a sample scan and a demo video:
https://www.dropbox.com/s/h21ke7cnlwjs9wi/2021-03-24_01-37-1...
My email can be found on my website (linked via my HN profile) if you want to discuss!
The uses would be endless, ranging from astrophotography to real professional-quality shots with homemade, scriptable cameras; shots synced with high-speed motion; a whole new era of homemade SLRs and mirrorless cameras that are actually competent; lots of things I can think of.
Of course it make little sense from financial point of view as good star tracker and optics are magnitudes more expensive but it was fun.
I agree with rest of your post. Even MFT-size sensor would be great as there are plenty great lenses with that image circle size.
Also I had lots of faint banding issues with RPi cameras. Nobody was able to solve my problem on forums.
My guess is that IMX477 does some software de-noise that causes banding. I tested this guess by calculating power spectrum of a dark frame and there was noticeable drop in higher frequencies. Unfortunately, even disabling hot-pixel detection did not help. I did not investigate it further.
Do you have plans or pics of how to do this? Especially how to do it without getting condensation on the electronics?
Thanks!
3mm thermal pad I used between PCB and cooler: https://botland.store/thermoconductive-tapes-pastes/6060-the...
Radiator (I used the smaller one that typically goes on cold side of Peltier): https://botland.store/peltier-elements/10024-heatsink-with-a...
Fan is standard 40mmx40mm, there is some generic copper thermal paste between Peltier and radiator. The plywood mount is DIY made with with hole drills. It is a bit too thick so I used 2x C-CS mount adapters (like the one bundled with the camera) to get more space, otherwise I would not be able to screw in lens adapter.
There was a bit of neoprene foam between radiator and fan to reduce vibrations but it looks like I lost it somewhere.
About condensation: it was always wet or even icy in operation but it never caused any electrical issues, I guess condensed water was not very conductive? Once on a cold night (about 5C) I had water condensation on the sensor itself but it did not cause any lasting damage. I've read that putting a fresh silica gel desiccant packet into lens adapter helps. I had plans to attach temperature probe to lens mount and control cooling power form Pi itself, will get back to it in the future. The camera sensor itself has embedded thermometer but it is not exposed in camera driver.
How close could one get in performance to a very costly astrophotography setup, for under $10k? Not counting the cost of the telescope/optics in front of it, just talking about the sensor part.
RPi foundation isn't really targeted at the niche, high-end, low-volume markets that demand the best of the best. They're great at delivering an excellent compromise of cost and quality. The IMX477 is just right for most use cases.
The sensor alone doesn't deliver 100% of the result of a modern SLR. The image processing code does a lot of heavy lifting that is mostly proprietary. The open source options are improving, but connecting an APS-C sensor to an R-Pi wouldn't automatically give you a DIY SLR competitor.
You'd spend a lot more in the process and get worse results than just buying a commercial SLR camera and running open-source scriptable firmware like Magic Lantern: https://magiclantern.fm/
Lenses for full frame cameras are super cheap -- you can find tons of old Russian, Japanese, and East German lenses that will work really well. Many of those lenses are built like tanks and can be had for <$100, some <$50. Most of them produce very nice images and aesthetically have much better look than what I see out of these CCTV lenses for the Pi HQ camera. CCTV lenses were never designed for art, and among other things produce horrible out-of-focus highlights.
> The image processing code
Well yes, that's also the point, by having an open source APS-C or full frame camera you can tinker to your heart's content with changing the image processing code.
I use Magic Lantern extensively and there's only so much you can do with it, and it's a pain in the ass to recompile code for it. Having a full-fledged Linux system with gcc, opencv, python, and pytorch at my disposal on camera, and with Wi-Fi, Bluetooth, USB, and running an SSH server, and the ability to connect arbitrary I2C and SPI sensors, would be freaking amazing, to say the least.
Wildlife camera with thermal camera trigger and a neural net that recognizes mountain lions? You got it.
LIDAR-based insanely accurate servo-driven autofocus? You got it.
Microphone array that figures out who in the picture is talking and refocuses the camera to that person? You got it.
Home-made Alt-Az tracker with built-in autoguider and remote Wi-Fi progress monitoring? You got it.
And if it can be made to work with the Pi, someone will hopefully also make it work with a Jetson Nano or Xavier NX and then voila I could do some neural net processing in real-time on-board. I've been able to blow Canon's in-camera denoising out of the water with state-of-the-art neural nets by postprocessing RAW images, and if I had a Xavier or Nano on-board I could easily put those neural nets in-camera for convenience.
The possibilities are endless, which is why I really want this hardware so much.
You don't need an APS-C or larger sensor to get decent images. Most APS-C sensors use a different high-speed interface that won't work with the Raspberry Pi anyway.
Really, this solution from the Raspberry Pi foundation is a great start for any of the projects you mentioned. It's also cheap and highly available.
I don't have the space and time to debate the merits here but there is a reason they exist, there are lots of things you can get by having a large sensor (including a different aesthetic and better SNR for low light images) and I want those things with a hackable interface and programmatic control of whatever the sensor is capable of.
I've been doing photography with full frame sensors for a a decade after upgrading from APS-C and telling me "you don't need an APS-C camera" without understanding why I use a full frame camera or the work I produce with them isn't really helpful.
I would love to have a nice APS-C or full frame board-level camera that can be easily integrated into something like a Raspberry Pi. At present it is nearly impossible to get something like that --- dev kits for large sensors from Sony Semicon, Canon, and ams are profoundly expensive, only sold to companies, and go through a lengthy quoting process.
> The sensor alone doesn't deliver 100% of the result of a modern SLR. The image processing code does a lot of heavy lifting that is mostly proprietary.
This is HN, hackers like us love to be able to tinker with the heavy lifting. That's the whole point of the Raspberry Pi cameras. Even with the current HQ camera, a used point-and-shoot camera with a similarly-sized sensor (or even bigger sensor) would tend to produce better images and videos while being more compact, robust, convenient, and cheaper than the DIY camera.
So in the astrophotography world they exist. This for example:
https://astronomy-imaging-camera.com/product/asi6200mc-pro-c...
uses an IMX455 full frame sensor, gives you a reasonably hackable full frame camera (not that well supported, but there are grassroots libraries around) but it's $4000 because it's also a cooled camera.
If they had a version of it that's not cooled and just for normal photography for $1000 that'd be awesome.
Where are you sourcing APS-C sized MIPI CSI sensors for a few hundred bucks in low quantities?
Larger sensors tend to use SLVS-EC interfaces rather than MIPI CSI used in the Raspberry Pi. The Raspberry Pi doesn't even support full 4-lane MIPI-CSI (except on the CM4). It's limited to 2-lane MIPI-CSI.
But I’d say an RPi alone would be a bit tough to handle something like this. You’d need at least an FPGA to control the sensor and maybe something like RPi for UI and further processing.
But it’ll be expensive. These components are anything between $500 and $3000, and that’s _without_ the FPGA and other things that would be required. An equivalent crop frame camera might be only $1000(?). If the aim is to have a DIY hackable camera, sure. If you want a cheap camera, no...
[1] https://media.digikey.com/pdf/Data%20Sheets/Canon%20USA%20PD... [2] https://ams.com/documents/20143/36005/CMV12000_DS000603_3-00...
https://github.com/ccrisan/motioneyeos
...has anyone used it?
https://home-assistant-guide.com/2020/10/08/building-a-video...
However, there is a super cool open source project from the author of GKrellM (remember that from the ancient days of Linux?). He's using the Pi's built-in hardware video coder to get high quality motion detection very cheaply. The basic idea seems to be, when the encoder produced a lot of bits, there must have been some motion in the frame.
i (deeply) reject your inquiry as a harmfully narrow, reductive consumerist ask, when this could be a much more neutral, open ended friendly question. you have qualified this from the start as a "solution," which is against the best premises, the best strengths of open source: "small pieces, loosely coupled."
the best software is small, purposeful, targetted. interwoven with other systems. only then is open source able to continue to focus on innovation & advancement, without becoming mired down in endless maintenance & complexity.
you should re-evaluate your ask, to ask for something that, will, in the end, not becoming limiting & ossified. open source ought best avoid the pretense commercial software competes on, of being a complete and final thing, of being everything to everyone. open source ought be more humble, and for this, it is better. ask, instead of a solution, after what systems of software might help one accomplish the home security systems they might want to build.
the best piece of open source home security cameras that I've seen is Frigate, which has masking & less interesting to me but probably interesting to many, object detection. designed for home assistant but it has other uses. much assembly required. good. solve your problem how you want to solve it: not how everyone else also has to.
i'd point out that home assistant itself is regarded by many as somewhat of an abomination, too big, unwieldy. core has 1.4k issues open and almost 300 PRs open. it's a shit show. it does way too much, it's way too monolithic, the project is basically doomed to stay where it is. it's a solution, and one that will rot & be no better in 3, 30, or 300 years: there's no open future here. it's only upside is that it is a plugin architecture, that it is an interoperation layer, that projects like Frigate can contribute & add capabilities too. home assistant is hugely popular, but basically it's core redeeming feature is that it allows small pieces, loosely coupled, to do something. home assistant itself is an anti-solution. frigate is an anti-solution. they are both parts, pieces, and in that is the strength. and hopefully, someday, we can kind a better system of pieces such that we can get rid of bloody ugly home assistant.
What stopped me was: 1) Raspberry PI boot-up time. It's long enough to prevent you from quickly snapping a picture when you see it - you have to be prepared. 2) Battery power that doesn't run down within a couple of days of non-use.
[1] https://mitxela.com/projects/thermal_paper_polaroid
[2] https://himeshp.blogspot.com/2018/08/fast-boot-with-raspberr...
With only a slight bit of patience, you can pick up something like a Panasonic Lumix ZS-6 for $30 on US eBay including shipping. Long battery life, fits in a pocket.
I removed the hot-mirror, epoxied a 720nm filter to the front and use mine for infra-red.
Only slightly larger, the Sony NEX C3 is a tiny APS-C camera, not much bigger than a point and shoot. It was the second iteration of the NEX3. Paired with the slightly more recent 16-50mm pancake zoom, it is a great everyday carry with 16mp.
To me, an rPi camera is an interesting idea and for a specialized use, its programmability would be an advantage. As an everyday camera, it's a bit absurd beyond telling people about it. YMMV.
Put a rPi in your other pocket.
Run chron.
At least it's not a pony and free M&M's.
It's nice for things like astronomy (your nice 200mm f/2.8 is now 1000mm+) or bird/nature watching, but it's highly impractical for anything but specialist portraiture or walk around use.
Most of the c mount lenses available are pretty poor, and getting focus right with anything not way stopped down (especially without a large display) can be super tricky.
That said, and assuming you use a camera module that you can disassemble far enough to expose the sensor, it shouldn't be too hard. You'd most easily I think design and 3D-print a replacement cover with a light-tight fitting to place the sensor on center at the flange focal distance (ie in the designed film plane), and route whatever cables out to where you could connect them. Maybe also a case for the Pi that has a 1/4"-20 screw to mount on the tripod socket, just so you don't have to cram your face past it to get a good look down the viewfinder.
You'd probably have a hard time getting anything like a wide-angle shot. I don't know offhand what sensor sizes are common in RPi camera modules, but I feel like expecting 1"-class would be expecting too much, so you'd be dealing with a pretty fierce crop factor.
The problem with retrofitting a film camera back with a Pi camera is that the Pi camera has a dinky little IMX477 sensor which only covers a small, small fraction of the area that would normally be illuminated on 35mm film, so you would not get very good images at all.
If they came out with a full-frame sensor that plugged into the Pi though, that would be awesome.
That said -- that's for 35mm cameras. Now there are also other film cameras ... I am working on using a Pi camera to scan a large format 4x5 area to bring a Toyo view camera back into the modern age :). It takes a good 15-20 minutes to scan the image and I get gigapixel results. Still a work in progress. Un-doing the effect of CRA optimization on the sensor's microlens array is annoying.
Stephen Johnson was playing around with this in the 1990's.
http://www.betterlight.com/field_photography.html
"I initially captured 180 degrees of view in a 6,000 x 40,055 pixel image, but soon learned that Photoshop was limited to opening files with less than 30,000 pixels in either dimension, so I had to perform surgery on the original TIFF file to reduce the image to just under this limit."
In general, film photography is having a comeback. Prices for used film cameras skyrocketed in the last years for a few models.
Personally, I find photographing on film really rewarding. Having a physical product in the end (be it a print of the image or only the negatives) makes the process more enjoyable. So if you have some old film cameras lying around, I can only recommend giving them a try. Maybe there are even old films with old memories in these cameras.
To get down into “normal” lens equivalent would require something like 8mm. A fisheye would probably be ok because the center tends to be relatively less distorted. But if there are 8mm rectilinear lenses for 35mm film cameras you probably can’t find one and maybe not afford one...Its price would buy a lot of film.
I mean there are digital sensors that retrofit film cameras. Products for Hasselblad 500 series and Mamiya RB have been around since the early days of digital. They have always been less than $100k and still are today.
Anyway if you want to use an old film camera, just buy some film and have a go. They are incredible mechanical devices and a pleasure in the hand and produce that film look naturally.
This is why companies like Apple use 6-axis active alignment machines to manufacture every camera module.
The "Megapixel" rating of a lens is based on the nominal as-designed MTF and image sensor Format. There's a lot of manufacturer fudging that goes on with these ratings. And some in China literally print whatever they want on the side of a lens. I've seen the same lens with both "3MP" and "5MP" printed on it.
Here are a few tips on how to focus a camera. Regardless, it'll be hard to get within 2-5 microns with a CS Mount 1"-32TPI thread. https://commonlands.com/blogs/technical/how-to-focus-a-camer...
I know it's a shitty way to specify lens resolution, but that's likely what the manufacturer called it, not the fault of the article's author.
[1] https://thepihut.com/products/raspberry-pi-high-quality-came...
To be sure the frame-grab tool could be sensing the lightless border from the image and cropping, but I doubt it's that clever.
The megapixel rating is an indicator for sharpness. There are more technical ways to rate sharpness, but listing the megapixel rating and sensor size is a quick way to suggest that the lens is sharp enough to resolve pixels that small.
It is not an optical standard.
C-mount lenses project image circles of different sizes depending on their intended use. The initial use was 8mm film cameras. But it was also used by lenses designed to cover the larger super8 film image standard. And today there is at least one c-mount lens that can nominally cover APS-C though with noticeable vignette...anyway...
The rPi camera sensor has a diagonal of 7.9mm. This is about 20% larger area than super8 film.
For a photographer whose opinions of image quality revolve around technical details, such a super8 format intended lens might produce about 10 “acceptable” megapixels on a 12mp sensor.
Most photographers tend to think about image quality in those terms. Limiting the specifications that way heads off complaints about unfulfilled expectations. It is easier to hold strong opinions about technical measures than to consider aesthetic possibility created by a lens’ optical limitations.
As many of the replies state, it doesn't make sense. I think the original author knew of the idea, but not the word. Now you can know the word :)