Question: Uploading images from raspberry pi.

cedarlodge is asking a question about raspberry-pi: Subscribe to answer questions on this topic

cedarlodge asked on February 27, 2018 11:06
250 | 1 answers | shortlink

I'm currently building a lego spectrometer with a pi zero W. Currently the images are being saved to a removable USB drive which I then plug into my laptop and upload to spectral workbench from there. The spectrometer itself is being controlled by a python script which I initiate over SSH.

Is there a way to upload to images direct to spectral workbench? Maybe through an API?

question:raspberry-pi question:pi-camera question:raspberry-pi-spectrometer question:lego-spectrometer


warren 4 months ago

Also, would you mind uploading or sharing some spectra you've taken? I'm eager to see some replications of the fairly new Lego design for verification! :-)

cedarlodge 4 months ago

Sure, so far I'm just doing test with CFL and halogen bulbs. The spectra I've uploaded do register as a bit dim, so I'm having to tinker with the camera settings in python. Can you use my username to see what I've uploaded?

Log in to comment

1 Answers

This is a great question and we need better (or just more refined) solutions. But there are a few options to start with:

  1. is designed to run on a Raspberry Pi and upload via the API.
  2. This question proposes a way forward by streaming video to or from a Raspberry Pi camera over a local network, which seems promising!

That last one is especially promising in combination with this idea of connecting the Raspberry Pi to a host computer via USB and running networking over that cable too which you're already involved in!

Thanks, @cedarlodge! We've got some great ways to make this process more seamless and I really appreciate your taking these next steps!

cedarlodge 4 months ago

Thanks for the help.

So far I've written a script in python which takes the photo, saves a copy to my media, then takes the middle line of pixels and converts it to a dataurl before trying to post it to spectral workbench. Problems I'm having so far:

Both chromium and python are throwing website certificate warnings at me, so I've had to work around that.

The post request returns a 200 code, but i'm not seeing anything new on my dashboard.

warren 4 months ago

Hmm, can you share your script, maybe on GitHub? I think the API is supposed to return a URL or at least a spectrum id.

warren 4 months ago

Also it's really exciting to have Python API code. Perhaps if you're interested we could host it as the "official" python API interface for SpectralWorkbench (whatever that means :-P) -- maybe "recommended" is the better word -- and list it for Python folks to use alongside SpectralWorkbench.js. So maybe Awesome!

cedarlodge 4 months ago

Here's the code I've been working on:

I've removed the features that are geared towards my specific spectrometer. I also had a go at tidying it up a little bit. I'm actually a science teacher by trade so my python knowledge is still a work in progress.

cedarlodge 4 months ago

I forgot to mention, the response.text is a long html document which looks like it might be Do I need to include my api token? I've attempted it but the response code comes back as 500.

warren 4 months ago

This is amazing!!!! Super great. I'll reply back to the issue in there.

MaggPi 3 months ago

Has anyone tried using computer vision software (openCV) to analyze the spectral data on the Raspberry PI? This may have lots of advantages since you could process spectral data at video frame rates. Anyone interested in collaborating please submit a response. Thank You MaggPI

cedarlodge 3 months ago

That sounds like a great idea. Can you recommend somewhere to get up to speed with OpenCV?

MaggPi 3 months ago

1)Check out: - - Good opencv-install video : 2)It looks like Mr Warren may be able to add the image sequencer on the Raspberry PI so you may have a non-website solution 3)It still may be worthwhile to use OpenCV for spectra preprocessing. For example, you could adjust camera integration time/white balance by feedback from analyzed spectra. The general approach may be to use a masked histogram but there may be better ways.

Log in to comment

Sign up or Login to post an answer to this question.