Skip to main content
Freeform - The esp8266 ssd1306 OLED freeform setup is now ready. I need to practice soldering more. Even though the freeform circuit is somewhat useable but it is not nearly as beautiful.

If any of you would like to try, I would like to advise you using female header pins as modules holder. You solder the header pins in proper places to the freeform wireframe according to your design. In that way, you will not unintentionally destroy your module boards should mishaps happened. Hopefully, after some more practice, we will produce some nice looking freeforms  fit for art exhibitions.

As I mentioned earlier, images taken by the esp32-cam needs to be downsized and converted. We need to change 1600x1200 JPG down to 128x64 PBM. I will do the whole process automatically in the finished product. The code below seems to work OK.

#!/usr/bin/python3

from PIL import Image, ImageEnhance

foto = Image.open("foto.jpg")
# crop
foto = foto.crop((0,200,1600,1000))
# convert
foto = foto.convert('L') # convert image to monochrome
# enhance
foto = ImageEnhance.Brightness(foto).enhance(2.0)  # 1.0 orig
foto = ImageEnhance.Contrast(foto).enhance(2.0)  # 1.0 orig
foto = ImageEnhance.Sharpness(foto).enhance(1.75) # 1.0 orig , max 2.0
# resize
foto = foto.resize((128,64),Image.ANTIALIAS)
# final convert
foto = foto.convert('1') # convert image to black and white
foto.save("foto4oled.pbm", quality=90, optimize=True)

 
This may not be the best way to do the conversion. You can certainly play around with image enhancement sequence order and their parameters. Experiment and you might get a better quality result.

Using python PIL we just need 10 lines of code to get the result we want. I am impressed and I will learn more about PIL. It will come handy for some future projects that I have in my plan.

Comments

Popular posts from this blog

Custom made - Sometimes, it is nice to be able to build custom made things. Thanks to Damien George and all the clever people at micropython.org for making it easy. So that, to custom build a micropython is not that difficult. Why do you want to build customize firmware anyway? Well, you might want to include some functionalities of your own and removed some functionalities from the standard distribution. The choices are there for you to make. I have a few changes that I want to make in micropython. version header -kaki5 (pronounce kaki-lima) an additional thread cleanup function for esp32 add frozen modules CryptoXo and uasyncio remove help, upip, and webrepl camera C module for esp32 camera board These are accomplished by modifying and adding files. py/makeversionhdr.py py/modthread.c extra/CryptoXo.py, extra/uasyncio.py, and manifest.py mpconfigport.h main.c and modcamera.c I also want to remove some modules specifically, help, upip, and webrepl from esp32...
Multi-threading : I previously used an uasyncio webcam server. This time around, I am testing a multi-thread webcam server. The result is promising. A multi-thread server seems to give a better throughput. The program logic is simpler when compared to the server based on uasyncio. The server is a four threaded application, two for port 80, one for port 81, and port 82 runs on the main thread, which blocks the REPL.  You can start a dedicated thread for port 82 if you do not want to block the REPL. I found pix/7 gives the best performance. A spe/2 will reduce the image size but give you a grayscale image. Please see my previous blog if all these seem mysterious to you. I have compiled a new firmware, MicroPython v1.11-571-g7e374d231.  You can download the new firmware from my repository at GitHub. The soft reset is not functioning properly. You need to do a hard reset. I also include four new functions in modcamera.c: pixformat agcgain aelevels aecvalue The pixfo...
Micropython - v1.11-498 introduced a few changes in the source-code directory structure. Changes to specific files, as previously described in esp32-cam , will no longer work. A simple working summary on how to build esp32-cam firmware is described below: Make a recursive copy of ports/esp32 to ports/esp32-cam, and you will need to modify the following files: 1) ports/esp32-cam/main.c 2) ports/esp32-cam/Makefile 3) ports/esp32-cam/modcamera.c 4) ports/esp32-cam/mpconfigport.h 5) ports/esp32-cam/boards/manifest.py 6) ports/esp32-cam/boards/sdkconfig.base Or, you can just download a precompiled Micropython v1.11-498 from firmware.bin at GitHub if you want to save some work. However, I encourage you to compile the firmware yourself. You will learn a lot and you can choose to modify anything to your liking. The modcamera.c includes something new. The still photo was taken using these settings; pix =8, con =2, qua =10, and spe =2. You will understand those parameters, later...