GithubHelp home page GithubHelp logo

johntigue / whiteboarder Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 105.64 MB

A two bit image processor app for whiteboard capture images

Home Page: http://tigue.com/whiteboarder_a_two_bit_photo_processor/

License: MIT License

Jupyter Notebook 99.99% Python 0.01%

whiteboarder's Introduction

Whiteboarder

Whiteboarder is a two-bit image processor for whiteboard capture photos. It is Python code released under an MIT license.

Although the utility is based on stock Python and Jupyter, the code has been optimized to run on Colab. Click the following button to try it out:

Demonstrations

brightfield_cuboid_packager.jpg:

red_kneecap.jpg:

git_and_jupyter_book.jpg:

See the demo directory for more before and after demonstrations.

whiteboarder's People

Contributors

johntigue avatar

Watchers

 avatar James Cloos avatar

whiteboarder's Issues

Draw text on header image

import requests
import PIL
from IPython.display import Image 
import PIL.ImageDraw

# Get background image
input_url = 'https://johntigue.github.io/whiteboarder/images/headers/four_pale_markers.png'
a_filename = '/content/four_pale_markers.png'
r = requests.get(input_url, allow_redirects=True)
open(a_filename, 'wb').write(r.content)

# Get font
!wget -O chunkfive.zip https://www.fontsquirrel.com/fonts/download/chunkfive
a_font = ImageFont.truetype('ChunkFive-Regular.otf', 50)

in_image = PIL.Image.open(a_filename)
img_draw = PIL.ImageDraw.Draw(in_image)
img_draw.text((652, 61), 'Whiteboarder', fill='#d01020', font=a_font)
img_draw.text((654, 175), 'A Two Bit Image Processor', fill='black', font=a_font)
img_draw.text((651, 288), 'Free Jupyter Based App', fill='#1010c0', font=a_font)
img_draw.text((653, 405), 'MIT Licensed Python', fill='green', font=a_font)
in_image.save('drawn_image.png')

pil_img = Image(filename='drawn_image.png')
display(pil_img)

[HUB] Bokeh

Hub issue for Bokeh

Bokeh discussion site:

Until March 2020, Bokeh was perfectly working on Google Colab. Some months ago with the new Colab version, it was not working anymore.

Bokeh discourse:

[2020-06] I think Google Colab finally upgraded to Bokeh 2.1.1. But now the export PNG that used to work with above code throws this error

Bokey discourse:

push_notebook does not function in Colab because Google actively blocks usage of notebook comms. Supposedly they are working to change this but we have no control over their schedule,

Thresholding: Li is doing gradient descent

skimage.filters.threshold_li():

initial_guessfloat or Callable[[array[float]], float], optional.
Li’s iterative method uses gradient descent to find the optimal threshold. If the image intensity histogram contains more than two modes (peaks), the gradient descent could get stuck in a local optimum. An initial guess for the iteration can help the algorithm find the globally-optimal threshold.

Is this "gradient descent" stocastic?

Test on JupyterLab

Maybe google stuff is conditionally imported? Can that even be done in python like:

if some_condition:
  import foo

Camera capture: higher res?

It sounds like there is a way to capture higher res camera image than currently being done.
https://colab.research.google.com/drive/1i2wiH26PtOhGPC3Sm10AJwYUB_koABBK#scrollTo=v1PIvTC8vYCs

# TODO: Want to try png for bigger file, no lossy compression.
  #
  # TODO: Higher res not: canvas.getContext('2d').drawImage(video, 0, 0);
  # https://developers.google.com/web/updates/2016/12/imagecapture
  # Previously, it was only possible to 'take a photo' by calling 
  #   drawImage() on a canvas element, using a video as the source (as per the example here).

See also #3

Publish results to a whiteboard capture blog

Each Colab session is essentially just injecting images into markdown blog posts.

  • input() to get a title and description.
  • HTTP POST/PUT somewhere persistent
    • Probably some SSGenerator
    • Hopefully GraphQL
  • Run Gatsby blog reader on dynamic GraphQL source

Features:

  • notebook ui should have a place to specify tags, title, description, or just full raw index.md since tags: is just another frontmatter line

Cropping

Manual and algorithmic (should be able to find the bounding box)

PNGs are causing error

Late in the pipeline someone doesn't like *.png files. Same file as *.jpeg works though

Line straightener

There have to be techniques for this. And there will probably be a slider to control some parameter.

witen first

  • camera
  • whiteboarder
  • tracer
  • cropper/clean-up

Blackboader

White (or colored) chalk on a blackboard. Same thing but inverted. So, black&white-boarder? Aww.

File Upload errored

Super lame.

Need to not error, but also need to figure out how to force scroll/focus on the output of the cell with the file select UI.

Rimshot: too loud

So:

  • grab a legal one
  • manipulate it to reduce volume
  • add to git repo
  • link to that modifed one

Global dial for image transfer size

Since all plot/show image code is in Whiteboarder component, rather than raw calls to UI libraries, this can be globally controlled.

  • Zero would mean don't waste any energy on UI, just run "headless"

More elegant would to have UI controls for that. I.e. user specifies how high quality to download. Starts at medium for decent performance by user can turn it up for inspection.

See also #34.

A good solution might be bokeh server. But it doesn't seem to work out of the box yet: https://discourse.bokeh.org/t/colabs-bokeh-server/5286

End-user, terse version

Consider specific shorter pipelines. E.g., one that does nothing except rolling ball background removal.

In Colab, take a pic with built-in camera

Colab's docs for capturing pics:

Using a webcam to capture images for processing on the runtime.

# Paraphrasing
from IPython.display import display, Javascript
from google.colab.output import eval_js
from base64 import b64decode

def take_photo(filename='photo.jpg', quality=0.8):
  js = Javascript('''
    async function takePhoto(quality) {
      ...
      const video = document.createElement('video');
      const stream = await navigator.mediaDevices.getUserMedia({video: true});
      await video.play();

      // Wait for Capture to be clicked.
      await new Promise((resolve) => capture.onclick = resolve);
      const canvas = document.createElement('canvas');
      ...
      return canvas.toDataURL('image/jpeg', quality);
    }
    ''')
  display(js)
  data = eval_js('takePhoto({})'.format(quality))
  binary = b64decode(data.split(',')[1])
  with open(filename, 'wb') as f:
    f.write(binary)
  return filename

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.