Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fun overlay demos #27

Closed
ladyada opened this issue Feb 9, 2024 · 3 comments · Fixed by #28
Closed

Fun overlay demos #27

ladyada opened this issue Feb 9, 2024 · 3 comments · Fixed by #28

Comments

@ladyada
Copy link
Member

ladyada commented Feb 9, 2024

@FoamyGuy
idea is to have a 'transparent background' frame file on the SD card or internal memeory that will be OR'd onto the image to give it a custom border! ideally the frame would also be visible in the preview

basically, simulate this:
image

@FoamyGuy
Copy link
Contributor

FoamyGuy commented Feb 9, 2024

Neat idea!

I haven't messed with any camera stuff much but I think this should be achievable.

Some thoughts about how for me to come back to:

The frame(s) image files can have "greenscreen" section for the center. It can be layered on top of the camera preview in displayio with ondiskbitmap or imageload Bitmap and the greenscreen color made transparent so it won't be drawn and the camera preview should show through.

For saving the images with the frame in them. It could possibly use adafruit_bitmapsaver to save a "screenshot" of the preview screen which will include the frame. Or if it's easier I think bitmaptools.blit() can be used to paste the frame Bitmap on top of a camera image Bitmap and the skip_index argument will allow it to skip the specified greenscreen color / section.

@justmobilize
Copy link

Oh that sounds awesome

@FoamyGuy
Copy link
Contributor

This turned out to be a little trickier than I made it sound, and I hit some unrelated hurdles along the way but I've gotten both previewing and saving with the overlay functional now. PR with library modifications and new example coming shortly.

Preview with overlay:
IMG_20240220_093729735_HDR_1

Final image with overlay (github doesn't allow .bmp files it seems):
img0032_modified.bmp.zip

There are a few things to note about it:

  • The .jpeg photos are still taken and originals are left untouched on the SDCard
  • The final output is .bmp not .jpeg so the filesize ends up a fair bit larger than the jpeg version of the photo
  • Saving the final .bmp uses a modified adafruit_bitmapsaver
  • Currently in order to combine the photo with the overlay both must be loaded into memory as Bitmap objects which are relatively large. I was able to use 640x480 size successfully but I believe that may be the largest one that can work, I do still need to test the next one up to confirm though.
  • It takes a noticeable amount of time to do decode the taken jpeg, then combine it with the overlay, and finally write it back out as a .bmp file. Smaller sized photos result in lower wait times. I haven't measured the time specifically but 640x480 was at least 45-60 seconds or more. 320x240 sized photo is around 30 seconds or a little less. I have not profiled it to figure out which steps take the most time, perhaps there are ways to be more efficient than my current code.
  • The overlay .bmp file can be on the CIRCUITPY drive or the SDCard. But with size 640x480 the .bmp is too large to fit on CIRCUITPY with the other necessary libraries and code so anyone wanting to take 640x480 sized photos must store the overlay file on the SDCard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants