Question: Uploading images from raspberry pi.

cedarlodge is asking a question about raspberry-pi
Follow this topic

by cedarlodge | February 27, 2018 11:06 | #15824


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?



12 Comments

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

  1. https://github.com/publiclab/spectral-workbench.js is designed to run on a Raspberry Pi and upload via the SpectralWorkbench.org API.
  2. This question proposes a way forward by streaming video to SpectralWorkbench.org or Infragram.org 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!

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.


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.

https://spectralworkbench.org/profile/cedarlodge

Is this a question? Click here to post it to the Questions page.


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 spectral-workbench.py? Awesome!

Is this a question? Click here to post it to the Questions page.


Here's the code I've been working on: https://github.com/classimago/spectral-workbench.py/

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.


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

Is this a question? Click here to post it to the Questions page.


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


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

Is this a question? Click here to post it to the Questions page.


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

Is this a question? Click here to post it to the Questions page.


1)Check out: - https://opencv.org/ - Good opencv-install video : https://www.youtube.com/watch?v=j6RD3X94rEA 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.

Is this a question? Click here to post it to the Questions page.


Reply to this comment...


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! :-)

Is this a question? Click here to post it to the Questions page.

Reply to this comment...


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?

Is this a question? Click here to post it to the Questions page.

Reply to this comment...


Log in to comment