elixir-vision / picam

Elixir library used to capture MJPEG video on a Raspberry Pi using the camera module.
Other
122 stars 27 forks source link

Add `Picam.FakeCamera` #24

Closed GregMefford closed 6 years ago

GregMefford commented 6 years ago

This adds a fake version of the Picam.Camera GenServer that can be used for testing on non-Raspberry Pi hardware, where the real camera isn't available.

The C code is already set up so this works by skipping compilation and generating the following warning:

Mix environment
  MIX_TARGET:   host
  MIX_ENV:      dev

==> picam
Makefile:18: raspijpgs only works on Linux on a Raspberry Pi. Crosscompilation
Makefile:19: is supported by defining at least $CROSSCOMPILE. See Makefile for
Makefile:20: details. If using Nerves, this should be done automatically.
Makefile:21: .
Makefile:22: Skipping C compilation unless targets explicitly passed to make.
make: Nothing to be done for `all'.

This warning is fine as it is IMO, but we could potentially add a note like this warning can be safely ignored if you're intentionally running with MIX_TARGET=host, or maybe we can somehow detect that this is the case and suppress the warning).

fhunleth commented 6 years ago

My 2 cents:

  1. This looks useful!

  2. I'm a little worried about maintaining it since every change to Camera is going to need to be replicated in FakeCamera. Do you have any ideas on how to force/encourage us to keep them synchronized?

  3. Also, I was going to say something about FakeCamera and images being installed even when they're not used. The files aren't all that big, though, so I don't think that it's worth coming up with some complicated way to prune them out for "real" builds. If you could run the images through an optimizer, that would be nice.

BTW, I don't know how others feel about this, but next time you forget to add a couple files, feel free to rebase and force push to hide the "oops" commit.

electricshaman commented 6 years ago

Awesome! Thanks @GregMefford.

GregMefford commented 6 years ago

Yep, I agree on all points, @fhunleth. I just needed this for my training next week, but I wanted to get it into the real Picam instead of forking my own version for training. There is definitely some room for improvement and I have some ideas about how to make it work more seamlessly, but out of time for refactoring at this stage.