Skip to content

Instantly share code, notes, and snippets.

@raganmd
Created June 16, 2022 21:44
Show Gist options
  • Save raganmd/123844877e8a364b4331691783014e8a to your computer and use it in GitHub Desktop.
Save raganmd/123844877e8a364b4331691783014e8a to your computer and use it in GitHub Desktop.
Google Drive ULR to TOP
# me - this DAT
# scriptOp - the OP which is cooking
import cv2
import numpy
import requests
# press 'Setup Parameters' in the OP to call this function to re-create the parameters.
def onSetupParameters(scriptOp):
page = scriptOp.appendCustomPage('Custom')
p = page.appendStr('Imageurl', label='Image URL')
return
# called whenever custom pulse parameter is pushed
def onPulse(par):
return
def onCook(scriptOp):
source = scriptOp.par.Imageurl.eval()
response = requests.get(source, stream=True)
if response.status_code == 200:
content = response.content
nppar = numpy.fromstring(content, numpy.uint8)
img_np = cv2.imdecode(nppar, cv2.IMREAD_COLOR)
rgb_img = cv2.cvtColor(img_np, cv2.COLOR_BGR2RGB)
rgb_img = cv2.flip(rgb_img, 0)
scriptOp.copyNumpyArray(rgb_img)
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment