Home

Exception thrown after camera_client.captureimage() in Vision AI Developer Kit

%3CLINGO-SUB%20id%3D%22lingo-sub-911497%22%20slang%3D%22en-US%22%3EException%20thrown%20after%20camera_client.captureimage()%20in%20Vision%20AI%20Developer%20Kit%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-911497%22%20slang%3D%22en-US%22%3E%3CP%3EWhile%20attempting%20the%20face%20detect%20sample%2C%20we%20find%20the%20vision%20sample%20container%20throws%20an%20exception%20after%20trying%20to%20run%20captureimage().%20We've%20logged%20an%20%3CA%20title%3D%22link%20to%20issue%20on%20github%22%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fvision-ai-developer-kit%2Fissues%2F251%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eissue%20on%20github%3C%2FA%3E%20including%20code%20details%20and%20stack%20trace%20and%20hope%20to%20get%20more%20traction%20here.%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Esend%3A%20b'%5Cx89%5Cx80%5Cxa3%5DI%2C'%0A2019-10-14%2001%3A40%3A44%2C863%20-%20iotccsdk%20-%20ERROR%20-%20camera%20-%20captureimage%3A602%20-%20true%0A%5BPKS%20INFO%5D%20Loading%20snapshot%20from%20file...%0AExpected%201%20file%20but%20got%200%0A2019-10-14%2001%3A40%3A45%2C042%20-%20iotccsdk%20-%20ERROR%20-%20camera%20-%20get_inferences%3A197%20-%20invalid%20file%3A%20None%0ATraceback%20(most%20recent%20call%20last)%3A%0A%20%20File%20%22%2Fusr%2Flocal%2Flib%2Fpython3.5%2Fdist-packages%2Fiotccsdk%2Fcamera.py%22%2C%20line%20195%2C%20in%20get_inferences%0A%20%20%20%20yield%20inference_iterator.start(self.vam_url)%0A%20%20File%20%22.%2Fmain.py%22%2C%20line%20134%2C%20in%20main%0A%20%20%20%20azure_face_api_detect(camera_client%2C%20iot_hub_manager)%0A%20%20File%20%22%2Fapp%2Fazure_face_api.py%22%2C%20line%2066%2C%20in%20azure_face_api_detect%0A%20%20%20%20image_data%20%3D%20open(get_snapshot_name()%2C%20%22rb%22)%0ATypeError%3A%20invalid%20file%3A%20None%0AException%20from%20get%20inferences%3A%0A%5B'Traceback%20(most%20recent%20call%20last)%3A%5Cn'%2C%20'%20%20File%20%22.%2Fmain.py%22%2C%20line%20134%2C%20in%20main%5Cn%20%20%20%20azure_face_api_detect(camera_client%2C%20iot_hub_manager)%5Cn'%2C%20'%20%20File%20%22%2Fapp%2Fazure_face_api.py%22%2C%20line%2066%2C%20in%20azure_face_api_detect%5Cn%20%20%20%20image_data%20%3D%20open(get_snapshot_name()%2C%20%22rb%22)%5Cn'%2C%20'TypeError%3A%20invalid%20file%3A%20None%5Cn'%5D%0A2019-10-14%2001%3A40%3A47%2C673%20-%20iotccsdk%20-%20ERROR%20-%20ipcprovider%20-%20on_error%3A341%20-%20Camera%20Restarted!%20Exiting!!%0AError%3A%20Time%3AMon%20Oct%2014%2001%3A40%3A48%202019%20File%3A%2Fusr%2Fsdk%2Fsrc%2Fc%2Fc-utility%2Fadapters%2Fsocketio_berkeley.c%20Func%3Asocketio_dowork%20Line%3A1006%20Socketio_Failure%3A%20Receiving%20data%20from%20endpoint%3A%20errno%3D104.%0AError%3A%20Time%3AMon%20Oct%2014%2001%3A40%3A48%202019%20File%3A%2Fusr%2Fsdk%2Fsrc%2Fc%2Fc-utility%2Fadapters%2Fsocketio_berkeley.c%20Func%3Asocketio_dowork%20Line%3A1006%20Socketio_Failure%3A%20Receiving%20data%20from%20endpoint%3A%20errno%3D104.%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3Eour%20dockerfile%20uses%20requirements.txt%20to%20install%20these%20libraries%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Erequests%0Aazure-iothub-device-client~%3D1.4.3%0Aiotccsdk%0Aazure%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EAny%20help%20would%20be%20appreciated%2C%20thank%20you.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-912351%22%20slang%3D%22en-US%22%3ERE%3A%20Exception%20thrown%20after%20camera_client.captureimage()%20in%20Vision%20AI%20Developer%20Kit%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-912351%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F423381%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3E%40sezflynn%3C%2FA%3E%20Thank%20you%20for%20highlighting%20this.%20I'm%20investigating%20and%20will%20get%20back%20soon.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-916404%22%20slang%3D%22en-US%22%3ERE%3A%20Exception%20thrown%20after%20camera_client.captureimage()%20in%20Vision%20AI%20Developer%20Kit%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-916404%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F423381%22%20target%3D%22_blank%22%3E%40sezflynn%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EUnfortunately%2C%20there%20is%20a%20known%20issue%20with%20the%20camera%20client%20api%20below%20the%20iotccsdk%2C%20where%20during%20a%20session%20a%20snapshot%20should%20be%20taken%20right%20after%20the%20camera%20is%20started%20to%20ensure%20stability%20of%20the%20snapshot%20function.%3C%2FP%3E%0A%3CP%3EIf%20an%20inference%20is%20detected%20before%20a%20test%20snapshot%20is%20taken%20first%20the%20snapshot%20fails%20and%20can%20crash%20the%20module.%20A%20quick%20way%20to%20work%20around%20the%20issue%20is%20to%20make%20sure%20the%20frame%20is%20clear%20of%20objects%20that%20will%20trigger%20inference%20during%20module%20startup.%20Say%2C%20for%20example%2C%20simply%20covering%20the%20camera%20lens%20for%20a%20few%20seconds%20while%20the%20module%20starts%20up.%3C%2FP%3E%0A%3CP%3EI've%20also%20posted%20this%20reply%20on%20the%26nbsp%3B%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20title%3D%22link%20to%20issue%20on%20github%22%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fvision-ai-developer-kit%2Fissues%2F251%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EGitHub%20issue%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ewhich%20you%20had%20opened.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

While attempting the face detect sample, we find the vision sample container throws an exception after trying to run captureimage(). We've logged an issue on github including code details and stack trace and hope to get more traction here.

send: b'\x89\x80\xa3]I,'
2019-10-14 01:40:44,863 - iotccsdk - ERROR - camera - captureimage:602 - true
[PKS INFO] Loading snapshot from file...
Expected 1 file but got 0
2019-10-14 01:40:45,042 - iotccsdk - ERROR - camera - get_inferences:197 - invalid file: None
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/iotccsdk/camera.py", line 195, in get_inferences
    yield inference_iterator.start(self.vam_url)
  File "./main.py", line 134, in main
    azure_face_api_detect(camera_client, iot_hub_manager)
  File "/app/azure_face_api.py", line 66, in azure_face_api_detect
    image_data = open(get_snapshot_name(), "rb")
TypeError: invalid file: None
Exception from get inferences:
['Traceback (most recent call last):\n', '  File "./main.py", line 134, in main\n    azure_face_api_detect(camera_client, iot_hub_manager)\n', '  File "/app/azure_face_api.py", line 66, in azure_face_api_detect\n    image_data = open(get_snapshot_name(), "rb")\n', 'TypeError: invalid file: None\n']
2019-10-14 01:40:47,673 - iotccsdk - ERROR - ipcprovider - on_error:341 - Camera Restarted! Exiting!!
Error: Time:Mon Oct 14 01:40:48 2019 File:/usr/sdk/src/c/c-utility/adapters/socketio_berkeley.c Func:socketio_dowork Line:1006 Socketio_Failure: Receiving data from endpoint: errno=104.
Error: Time:Mon Oct 14 01:40:48 2019 File:/usr/sdk/src/c/c-utility/adapters/socketio_berkeley.c Func:socketio_dowork Line:1006 Socketio_Failure: Receiving data from endpoint: errno=104.

our dockerfile uses requirements.txt to install these libraries:

requests
azure-iothub-device-client~=1.4.3
iotccsdk
azure

Any help would be appreciated, thank you.

2 Replies
Highlighted

@sezflynn Thank you for highlighting this. I'm investigating and will get back soon.

Highlighted

@sezflynn 

Unfortunately, there is a known issue with the camera client api below the iotccsdk, where during a session a snapshot should be taken right after the camera is started to ensure stability of the snapshot function.

If an inference is detected before a test snapshot is taken first the snapshot fails and can crash the module. A quick way to work around the issue is to make sure the frame is clear of objects that will trigger inference during module startup. Say, for example, simply covering the camera lens for a few seconds while the module starts up.

I've also posted this reply on the  GitHub issue which you had opened.

Related Conversations
REST API question : downloading attachments
nigelgomm in Office 365 on
0 Replies
Annotate Function in Teams
Frank_Matic in Microsoft Teams on
0 Replies
Teams bot with dynamic endpoint url
SujayBawaskar in Teams Developer on
0 Replies
Mega Menu Target audience
Moe_Kinani in SharePoint on
2 Replies