Skip to content

Instantly share code, notes, and snippets.

@tendstofortytwo
Created December 14, 2017 08:29
Show Gist options
  • Save tendstofortytwo/d791ddf3afcbf377ba55cc8c87556f24 to your computer and use it in GitHub Desktop.
Save tendstofortytwo/d791ddf3afcbf377ba55cc8c87556f24 to your computer and use it in GitHub Desktop.
Origami-lib sendImageArray Numpy Array example
import cv2
import origami
# all memory/processor intensive work that is to be done only once (like loading models) goes here
# replace $TOKEN with your app token generated by web app
app = origami.register('$TOKEN')
@origami.crossdomain
@app.listen()
def hello():
# get two images from user
input = origami.getImageArray(mode='numpy_array')
# images obtained are numpy arrays
image_1 = input[0]
image_2 = input[1]
# sample modification on images
gray_image_1 = cv2.cvtColor(image_1, cv2.COLOR_BGR2GRAY)
gray_image_2 = cv2.cvtColor(image_2, cv2.COLOR_BGR2GRAY)
# send back modified images
origami.sendImageArray([gray_image_1, gray_image_2], mode='numpy_array')
return 'OK'
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment