What will i do?

I just want the AI to see my screen and highlight things from the dataset on it. What should I do once the neural network is trained?

Describe your question/issue here! (delete this when you post)

  • Project Type:
  • Operating System & Browser:
  • Project Universe Link or Workspace/Project ID:
  • Do you grant Roboflow Support permission to access your Workspace for troubleshooting? (Yes/No):

Got an answer from AI you could try - you use OBS Studio to stream your screen as a virtual webcam and run your model against that. Code (untested) is below.

import cv2
import base64
import numpy as np
import requests

ROBOFLOW_API_KEY = "YOUR_KEY"
ROBOFLOW_MODEL = "your-model-id"
ROBOFLOW_SIZE = 416

upload_url = "".join([
    "https://detect.roboflow.com/",
    ROBOFLOW_MODEL,
    "?access_token=",
    ROBOFLOW_API_KEY,
    "&format=image",
    "&stroke=5"
])

# Use OBS virtual camera instead of default webcam
video = cv2.VideoCapture(1)  # 0 = default cam, 1 = OBS virtual cam on many systems

def infer():
    ret, img = video.read()
    height, width, _ = img.shape
    scale = ROBOFLOW_SIZE / max(height, width)
    img = cv2.resize(img, (round(scale * width), round(scale * height)))

    retval, buffer = cv2.imencode('.jpg', img)
    img_str = base64.b64encode(buffer)

    resp = requests.post(upload_url, data=img_str, headers={
        "Content-Type": "application/x-www-form-urlencoded"
    }, stream=True).raw

    image = np.asarray(bytearray(resp.read()), dtype="uint8")
    image = cv2.imdecode(image, cv2.IMREAD_COLOR)
    return image

while True:
    if cv2.waitKey(1) == ord('q'):
        break
    image = infer()
    cv2.imshow('image', image)

video.release()
cv2.destroyAllWindows()

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.