Skip to content

Commit

Permalink
avoid stop capture if isCapturing
Browse files Browse the repository at this point in the history
  • Loading branch information
hairygael authored Jan 2, 2025
1 parent 34a0851 commit ee7ec17
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions services/L_Llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,36 @@ def onPredicate(predicateEvent):
def describeImage(prompt):
if runtime.isStarted('i01.llmImg'):
llmImg = runtime.getService('i01.llmImg')
opencv = runtime.start('i01.opencv', 'OpenCV')
# make a subscription
i01_llmImg.subscribe('i01.opencv','publishImage')
#img = i01_llmImg.subscribe('i01.opencv','publishImage')
#response = llmImg.getImageResponse(img,prompt)
#llmImg.invoke("getResponse",["Always respond in french with a short description.", [img]])
# capture and save an image
# the save image will be publishImage and be sent
# to the llmImg
opencv.capture()
opencv.saveImage()
sleep(0.1)
opencv.stopCapture()

if runtime.isStarted('i01.opencv'):
opencv = runtime.getService('i01.opencv')
if opencv.isCapturing():
# make a subscription
i01_llmImg.subscribe('i01.opencv','publishImage')
# capture and save an image
# the save image will be publishImage and be sent
# to the llmImg
opencv.saveImage()
else:
# make a subscription
i01_llmImg.subscribe('i01.opencv','publishImage')
# capture and save an image
# the save image will be publishImage and be sent
# to the llmImg
opencv.capture()
opencv.saveImage()
sleep(0.1)
opencv.stopCapture()
else:
opencv = runtime.start('i01.opencv', 'OpenCV')
# make a subscription
i01_llmImg.subscribe('i01.opencv','publishImage')
# capture and save an image
# the save image will be publishImage and be sent
# to the llmImg
opencv.capture()
opencv.saveImage()
sleep(0.1)
opencv.stopCapture()

else:
llmImg = runtime.start('i01.llmImg', 'LLM')
Expand Down

0 comments on commit ee7ec17

Please sign in to comment.