@@ -50,42 +50,51 @@ Keep your API token secure! Anyone who has access to it can impersonate you and
5050
5151### Call the Groundlight API
5252
53- Call the Groundlight API by creating a ` Detector ` and submitting an ` ImageQuery ` .
54-
55- For example, lets say we have captured this image and saved it under ` ./docs/static/img/thumbs-up.jpg ` :
56- <img
57- src = { require (' /img/thumbs-up.jpg' ).default }
58- alt = " Thumbs-Up Example Image"
59- width = { " 50%" }
60- />
61- <br />
62- <br />
63-
64- We can now use Groundlight to ask a question about the image:
53+ Call the Groundlight API by creating a ` Detector ` and submitting an ` ImageQuery ` . A ` Detector ` represents a specific
54+ visual question you want to answer, while an ` ImageQuery ` is a request to analyze an image with that question.
55+
56+ The Groundlight system is designed to provide consistent, highly confident answers for similar images
57+ (such as frames from the same camera) when asked the same question repeatedly. This makes it ideal for
58+ monitoring scenarios where you need reliable visual detection.
59+
60+ Let's see how to use Groundlight to analyze an image:
6561``` python title="ask.py"
6662from groundlight import Groundlight, Detector, ImageQuery
63+ from framegrab import FrameGrabber
6764
6865gl = Groundlight()
6966
7067detector = gl.get_or_create_detector(detector_name, detector_query)
7168detector: Detector = gl.get_or_create_detector(
72- name = " thumbs-up " ,
73- query = " Is the thumb facing up ?" ,
69+ name = " eagle-detector " ,
70+ query = " Is there an eagle visible ?" ,
7471)
7572
76- img = " ./docs/static/img/thumbs-up.jpg" # Image can be a file or a Python object
77- image_query = gl.submit_image_query(detector = det, image = img)
73+ config = {
74+ ' input_type' : ' youtube_live' ,
75+ ' id' : {
76+ # Big Bear Bald Eagle Nest live-stream
77+ ' youtube_url' : ' https://www.youtube.com/watch?v=B4-L2nfGcuE'
78+ }
79+ }
80+
81+ with FrameGrabber.create_grabber(config) as grabber:
82+ frame = grabber.grab()
83+ if frame is None :
84+ raise Exception (" No frame captured" )
85+
86+ image_query = gl.submit_image_query(detector = det, image = frame)
7887
7988print (f " The answer is { image_query.result.label} " )
8089print (image_query)
8190```
8291
83- Run the code using ` python ask.py ` . The code will submit an image to the Groundlight API and print the result:
92+ Run the code using ` python ask.py ` . The code will submit an image from the live-stream to the Groundlight API and print the result:
8493```
85- The answer is NO
94+ The answer is YES
8695ImageQuery(
8796 id='iq_2pL5wwlefaOnFNQx1X6awTOd119',
88- query="Is the thumb facing up?" ,
97+ query="Is there an eagle visible? ,
8998 detector_id='det_2owcsT7XCsfFlu7diAKgPKR4BXY',
9099 result=BinaryClassificationResult(
91100 confidence=0.9995857543478209,
0 commit comments