publiclab / pi-builder

Developing a reproducible build script system for making Raspberry Pi .img files
MIT License
22 stars 15 forks source link

Install infragram #37

Closed jywarren closed 6 years ago

jywarren commented 6 years ago

Thanks for opening a pull request! In this repository, opening a PR will initiate the generation of a new Raspberry Pi image, and create an image file you can download and use in your Raspberry Pi.

The changes you add to the pull request, such as adding software to install, will be run on the generated image.

For an example, see the software installed and configured in this pull request: https://github.com/publiclab/image-builder-rpi/pull/15/files

Recipe

Use this space to describe what your "recipe" is intended to install and configure on a Raspberry Pi:

Installing Infragram multispectral analysis tool: https://github.com/publiclab/infragram


Download instructions

Generating the image will take a few minutes. Once the image is prepared, and if it succeeded, you'll see a green checkmark at the bottom of the pull request. To download the image:

  1. click the green checkmark; you'll go to a page at a URL like https://gitlab.com/publiclab/image-builder-rpi/pipelines/########/builds
  2. On this page, click the Jobs tab, next to Pipeline
  3. Click the green Passed button
  4. Click Download in the right-hand sidebar
  5. Unzip the artifacts.zip file, and also the hypriotos-rpi-camera_web.img.zip within it
  6. Use a program like https://etcher.io/ to flash it to an SD card

You'll also be able to read the output of the image generation in this window.

We hope to create a bot to report back the completed image URL in each pull request. If you can help create such a bot, please contact us at:

https://github.com/publiclab/image-builder-rpi/issues/16

Thanks!

jywarren commented 6 years ago

Oh, did our rename break the building system, @icarito ? Sorry!!!

icarito commented 6 years ago

No the rename didn't break the build. There was a temporary network issue I think. I retried and now it failed because npm isn't installed.

jywarren commented 6 years ago

What's the ideal way to install npm -- trying sudo apt-get install nodejs npm node-semver per https://raspberrypi.stackexchange.com/questions/4194/getting-npm-installed-on-raspberry-pi-wheezy-image

maykef commented 6 years ago

Hi, I think is a better idea to implement image-sequencer within the pi-image, rather than infragram. The other thing to take into consideration, at least in my case, is that the compute module has just 4GB of space and therefore any image bigger than that would not be suitable for it. I've got an image for the CM 3 with opencv installed, and maybe there is space for image-sequencer. That would make it a killer in processing terms

jywarren commented 6 years ago

oh, i'd like to do both, this is just an initial example attempt! I definitely think we should create an image-sequencer version of this too.

On Tue, Oct 23, 2018 at 2:26 PM Mayke De Freitas notifications@github.com wrote:

Hi, I think is a better idea to implement image-sequencer within the pi-image, rather than infragram. The other thing to take into consideration, at least in my case, is that the compute module has just 4GB of space and therefore any image bigger than that would not be suitable for it. I've got an image for the CM 3 with opencv installed, and maybe there is space for image-sequencer. That would make it a killer in processing terms

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/publiclab/pi-builder/pull/37#issuecomment-432363758, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJ5J8cycuuPw9B9dejAq1j6wQjN1Cks5un18YgaJpZM4X0Uf8 .

jywarren commented 6 years ago

Now following https://www.thepolyglotdeveloper.com/2018/03/install-nodejs-raspberry-pi-zero-w-nodesource/

jywarren commented 6 years ago

So once we get this running, we should be able to just swap "infragram" with "image-sequencer" in a new PR and then it should work there too. They have similar node/npm dependencies!

jywarren commented 6 years ago

Ah, we're now running out of space -- is there a way to expand the image?

tar: ./node-v9.7.1-linux-armv6l: Cannot mkdir: No space left on device
tar: ./node-v9.7.1-linux-armv6l/lib/node_modules/npm/lib/install/exists.js: Cannot open: No such file or directory
icarito commented 6 years ago

Yes! I ran into the same issue while trying to integrate Peggy scripts + Desktop environment. Please see https://github.com/publiclab/pi-builder/pull/12/files#diff-55f0a4e44112d8684fa3f85db6490f3cL87

This replaces the standard hypriot root base filesystem with a custom built one by us in Jenkins (set to 2GB instead of 1GB images).

icarito commented 6 years ago

The repository for the enlarged rootfs is at https://gitlab.com/publiclab/image-builder-raw

jywarren commented 6 years ago

OK! Added that to increase the image size. Awesome, thanks!

jywarren commented 6 years ago

Hmm, i'm seeing this error now:

+ wget -q -O /workspace/rpi-raw.img.zip https://jenkins.laboratoriopublico.org/job/image-builder-raw/ws/rpi-raw.img.zip
+ sha256sum -c -
+ echo '2fbeb13b7b0f2308dbd0d82780b54c33003ad43d145ff08498b25fb8bbe1c2c6 /workspace/rpi-raw.img.zip'
/workspace/rpi-raw.img.zip: FAILED
sha256sum: WARNING: 1 computed checksum did NOT match

I'm restarting it to see, but any ideas what this is about? Thanks!

jywarren commented 6 years ago

Seems linked to this checksum? https://github.com/publiclab/pi-builder/blob/9aa7e739dd8fe1e250f5b74cff4e74a4bd6ce177/versions.config

icarito commented 6 years ago

Yes, it is necessary to update the checksum too, forgot to mention it: https://github.com/publiclab/pi-builder/pull/12/files#diff-228984280290be5309df88a7d32cf31dL8

jywarren commented 6 years ago

It worked!!!

jywarren commented 6 years ago

Er, did it? Oh, it doesn't seem to have triggered.

icarito commented 6 years ago

How strange, this should trigger automatically...

icarito commented 6 years ago

I found a webhook confused about the old URL, fixing it...

jywarren commented 6 years ago

Downloading this now to test! https://gitlab.com/publiclab/pi-builder/-/jobs/112353386/artifacts/download

jywarren commented 6 years ago

It worked!!! OK, so now I have to rebase this or combine it with commits from https://github.com/publiclab/pi-builder/pull/13/files, because we actually need that installed to be able to route the video stream into Infragram as per:

https://publiclab.org/questions/warren/12-05-2017/how-can-we-stream-video-to-spectralworkbench-org-or-infragram-org-from-a-raspberry-pi-camera

jywarren commented 6 years ago

Looks like you can just load it as an image using this code, and insert it:

var piImage = new Image();
piImage.onload = function() {
  infragram.options.processor.updateImage(piImage);
}
var fetchImageInterval = setInterval(function fetchImage() {
  piImage.src = "http://pi.local/cam/cam_pic.php?time=" + new Date().getTime();
}, 200);

(Updated again)

jywarren commented 6 years ago

Looking at this file: https://github.com/publiclab/infragram/blob/063acbf333ea45e980ffb56ad5d79cdc6a66391f/src/io/camera.js#L83

needs some experimentation!

jywarren commented 6 years ago

OK, I've rebased this over the camera_web branch that includes the PiCam web software, and opened a separate PR for it to test. If it works, we could move over there (for a cleaner PR) or close that and merge it back in here, depending on what people want.

jywarren commented 6 years ago

Wow, this worked:

screen shot 2018-10-26 at 4 07 59 pm

I'm super excited about this! Although I'm having trouble with the v2 NOIR camera.

Next - add a button to initiate this script and then do some tidying up in the Infragram repository...

jywarren commented 6 years ago

OK! I'm closing in favor of the tidier #40 -- this is working! Infragram may need some tidying but otherwise this is good to go, and can be used as a template for doing the same with image-sequencer too!

jywarren commented 6 years ago

@maykef i'm interested in learning more about CM 3 -- do you have a link? As to OpenCV, there are 2 approaches. First, this recipe uses OpenCV: https://github.com/publiclab/pi-builder/pull/12

Second, we have a module in planning for image-sequencer that uses the cross-compiled OpenCV.js: https://github.com/publiclab/image-sequencer/issues/237 -- this might be really interesting because it'd be so modular.

maykef commented 6 years ago

Hey @jywarren I've been working like crazy on the camera. I think I've done most of the hardest part. The cameras trigger within half millisecond (thanks to using multiprocessing module).

Here is a nice pic I took a couple of days ago:

clip_raspicam . And here the almost simultaneous trigger:

multispectral_cam_sync

jywarren commented 6 years ago

oh my gosh, please post some pics of your setup at PublicLab.org -- very cool!!!!

On Thu, Nov 1, 2018 at 12:27 PM Mayke De Freitas notifications@github.com wrote:

Hey @jywarren https://github.com/jywarren I've been working like crazy on the camera. I think I've done most of the hardest part. The cameras trigger within half millisecond (thanks to using multiprocessing module).

Here is a nice pic I took a couple of days ago:

[image: clip_raspicam] https://user-images.githubusercontent.com/19354019/47864238-070dc580-ddf1-11e8-9fc2-f1e9c75335c9.png . And here the almost simultaneous trigger:

[image: multispectral_cam_sync] https://user-images.githubusercontent.com/19354019/47864892-a3849780-ddf2-11e8-920d-d163acc7531a.jpg

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/pi-builder/pull/37#issuecomment-435093954, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJ6wJmmngffPM5TcHEWyTnpKtRU2Eks5uqyDbgaJpZM4X0Uf8 .

maykef commented 6 years ago

Are we running a Kickstarter campaign for this?

jywarren commented 6 years ago

lol should we? :-)

On Thu, Nov 1, 2018 at 2:44 PM Mayke De Freitas notifications@github.com wrote:

Are we running a Kickstarter campaign for this?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/pi-builder/pull/37#issuecomment-435141937, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJ2fPjjJlixhpwN0BPnG2Sa6m_w_xks5uq0DigaJpZM4X0Uf8 .

maykef commented 6 years ago

@jywarren Hey I have finished with most of the work for the multispectral pi. What I want to do now is to run image-sequencer from a web browser accessed through an access point on the pi. Image-sequencer should show the four images captured by the camera and then do all the processing

jywarren commented 6 years ago

Ooh, ok! Remind me, are you using 2 cameras? And what are the commands to take your images?

Awesome! I have image sequencer running on the pi already, so it's a matter of connecting it up w the camera scripts. 👍🏽

On Fri, Nov 16, 2018, 9:11 AM Mayke De Freitas <notifications@github.com wrote:

@jywarren https://github.com/jywarren Hey I have finished with most of the work for the multispectral pi. What I want to do now is to run image-sequencer from a web browser accessed through an access point on the pi. Image-sequencer should show the four images captured by the camera and then do all the processing

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/pi-builder/pull/37#issuecomment-439404379, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJxB1f2nWa33WsToKaGRrKVYKFEioks5uvsdogaJpZM4X0Uf8 .

maykef commented 6 years ago

Hi @jywarren,

Have a look to the Raspicam repo https://github.com/maykef/Raspicam

jywarren commented 6 years ago

oh interesting, but can you explain what the 4 images are? I am not quite following, it's 2 cameras, right? Thank you and sorry for being dense!

On Sat, Nov 17, 2018 at 3:28 AM Mayke De Freitas notifications@github.com wrote:

Hi @jywarren https://github.com/jywarren,

Have a look to the Raspicam repo https://github.com/maykef/Raspicam

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/pi-builder/pull/37#issuecomment-439599659, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJyF6hYiqUtozJ34P0LJ8JLYUq3g1ks5uv8ipgaJpZM4X0Uf8 .

maykef commented 6 years ago

No worries. These are the 4 bands. Camera one captures the R, G and B, while camera 2 collects the NIR band(845nm):

screenshot 2018-11-20 at 22 52 08
jywarren commented 6 years ago

Oh, of course. Sorry, when i process, i usually have 3 bands in one image, and another in a second, so mentally i think of 2 images.

So you're accessing it with picamera.PiCamera(0) and picamera.PiCamera(1) -- we need to figure out how to fetch images from both cameras. I'll open a new issue for this!

maykef commented 6 years ago

Apart from fetching the images, we need to think about image registration within Infragram. I've got an OpenCV script that already does the job, but the CM seems to run out of memory while doing the registration.