Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Exception thrown at camera_client.captureimage() #251

Closed
sezflynn opened this issue Oct 14, 2019 · 6 comments
Closed

Exception thrown at camera_client.captureimage() #251

sezflynn opened this issue Oct 14, 2019 · 6 comments
Assignees
Labels
SupportNeeded Help needed to get unblocked or to get an answer to a question

Comments

@sezflynn
Copy link

Face detect sample fails when camera client attempts to capture image.

We removed threading and changed main.py to this:

while True:
  try:
    while camera_client.vam_running and not person_detected: # added not person_detected to stop loop once person is detected
      with camera_client.get_inferences() as results:
        for result in results:
          if is_person(result, last_time):
            print("[PKS INFO] Confirmed - object is a person!")
            person_detected = True # <---- added 
            azure_face_api_detect(camera_client, iot_hub_manager)
            # original async code
            # face_api_thread = threading.Thread(
            #     target=azure_face_api_detect,
            #     args=(camera_client, iot_hub_manager))
            # face_api_thread.start()
           last_time = print_inference(
             result, iot_hub_manager, last_time)

and added logging to azure_face_api.py:

def azure_face_api_detect(camera_client=None, iot_hub_manager=None):
    # sends snapshot to azure face api to detect faces and features
    remove_old_snapshots(dir_name, file_name)
    print("[PKS INFO] Attempting camera capture...")
    camera_client.captureimage() # <--- iotccsdk error is logged after this command

    detect_face_api_url = face_api_url + '/face/v1.0/detect'

    headers = {'Content-Type': 'application/octet-stream',
               'Ocp-Apim-Subscription-Key': subscription_key}
    params = {
            'returnFaceId': 'true',
            'returnFaceLandmarks': 'false',
            'returnFaceAttributes': 'age,gender,headPose,smile,facialHair,glasses,' +
            'emotion,hair,makeup,occlusion,accessories,blur,exposure,noise'
    }

    print("[PKS INFO] Loading snapshot from file...") 
    image_data = open(get_snapshot_name(), "rb") # <--- exception thrown when this method fails to find a (snapshot?) file
    print("[PKS INFO] Snapshot successfully loaded")
    print("[PKS INFO] Face api url = " + detect_face_api_url)
    response = requests.post(detect_face_api_url, params=params, headers=headers, data=image_data)
    response.raise_for_status()
    faces = response.json()
    print(faces)

Here's a dump of the logs:

Create model_util
Create properties
Init Properties
Init CameraProperties
Init ModelProperties
Model already present and force update set to false

Python 3.5.2 (default, Jul 10 2019, 11:58:48)
[GCC 5.4.0 20160609]

Found IP: 192.168.72.18
ip address = 192.168.72.18
Create camera with no ipc_provider
2019-10-14 01:40:16,140 - iotccsdk - INFO - ipcprovider - connect:264 - API: http://192.168.72.18:1080/login data: {'userpwd': '<redacted>', 'username': 'admin'}
2019-10-14 01:40:20,484 - iotccsdk - INFO - ipcprovider - connect:266 - Login response: {"status":true}
2019-10-14 01:40:20,486 - iotccsdk - INFO - ipcprovider - connect:271 - connection established with session token: [session=36459eabd72]
2019-10-14 01:40:20,486 - iotccsdk - INFO - ipcprovider - __init__:326 - Connecting to: ws://192.168.72.18:1080/async
2019-10-14 01:40:20,489 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.18:1080/video data {}
--- request header ---
GET /async HTTP/1.1
Upgrade: websocket
Connection: Upgrade
Host: 192.168.72.18:1080
Origin: http://192.168.72.18:1080
Sec-WebSocket-Key: <redacted>
Sec-WebSocket-Version: 13


-----------------------
--- response header ---
HTTP/1.1 101 Switching Protocols
2019-10-14 01:40:20,505 - iotccsdk - INFO - camera - _get_supported_params:313 - resolutions: ['4K', '1080P', '720P', '480P']
2019-10-14 01:40:20,506 - iotccsdk - INFO - camera - _get_supported_params:314 - encodetype: ['HEVC/H.265', 'AVC/H.264']
2019-10-14 01:40:20,507 - iotccsdk - INFO - camera - _get_supported_params:315 - bitrates: ['512Kbps', '768Kbps', '1Mbps', '1.5Mbps', '2Mbps', '3Mbps', '4Mbps', '6Mbps', '8Mbps', '10Mbps', '20Mbps']
Upgrade: websocket
2019-10-14 01:40:20,508 - iotccsdk - INFO - camera - _get_supported_params:316 - framerates: [24, 30]
2019-10-14 01:40:20,508 - iotccsdk - INFO - camera - _get_supported_params:318 - Current preview settings:
2019-10-14 01:40:20,509 - iotccsdk - INFO - camera - _get_supported_params:319 - resolution: 1080P
2019-10-14 01:40:20,510 - iotccsdk - INFO - camera - _get_supported_params:320 - encodetype: AVC/H.264
2019-10-14 01:40:20,511 - iotccsdk - INFO - camera - _get_supported_params:321 - bitrate: 1.5Mbps
Connection: Upgrade
2019-10-14 01:40:20,512 - iotccsdk - INFO - camera - _get_supported_params:322 - framerate: 30
2019-10-14 01:40:20,513 - iotccsdk - INFO - camera - _get_supported_params:323 - display_out: 1
Configuring camera_client
2019-10-14 01:40:20,514 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.18:1080/overlay data {'switchStatus': False}
Sec-WebSocket-Accept: <redacted>
-----------------------
2019-10-14 01:40:20,522 - iotccsdk - INFO - ipcprovider - on_open:347 - Starting heartbeat...
Turning analytics off
Turning preview off
2019-10-14 01:40:20,529 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.18:1080/preview data {'switchStatus': False}
2019-10-14 01:40:20,541 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.18:1080/preview data {}
2019-10-14 01:40:20,553 - iotccsdk - INFO - camera - _get_preview_info:382 - preview url: None
Configure preview (1080P, AVC/H.264, 1.5Mbps, 30, 1)
2019-10-14 01:40:20,554 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.18:1080/video data {'resolutionSelectVal': 1, 'encodeModeSelectVal': 1, 'fpsSelectVal': 1, 'displayOut': 1, 'bitRateSelectVal': 3}
set preview state: on
2019-10-14 01:40:20,572 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.18:1080/preview data {'switchStatus': True}
2019-10-14 01:40:21,337 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.18:1080/preview data {}
2019-10-14 01:40:21,361 - iotccsdk - INFO - camera - _get_preview_info:382 - preview url: rtsp://192.168.72.18:8900/live
configure_overlay: inference
2019-10-14 01:40:21,362 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.18:1080/overlayconfig data {'ov_width': 0, 'ov_height': 0, 'ov_start_x': 0, 'ov_type_SelectVal': 5, 'ov_color': '869007615', 'ov_start_y': 0, 'ov_usertext': 'Text', 'ov_position_SelectVal': 0}
configure_overlay_state: on
2019-10-14 01:40:21,406 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.18:1080/overlay data {'switchStatus': True}
set_analytics_state: on
2019-10-14 01:40:21,420 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.18:1080/vam data {'vamconfig': 'MD', 'switchStatus': True}
2019-10-14 01:40:25,471 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.18:1080/vam data {}
2019-10-14 01:40:25,508 - iotccsdk - INFO - camera - _get_vam_info:431 - RESPONSE: {'ct_port': '', 'fr_port': '', 'status': True, 'url': 'rtsp://192.168.72.18:8902/live', 'md_port': ''}:
2019-10-14 01:40:25,509 - iotccsdk - INFO - camera - _get_vam_info:444 - vam url: rtsp://192.168.72.18:8902/live
Creating IoT Hub manager
Subscribing to method calls
send: b'\x89\x80\xa6W\xbbH'
Subscribing to module twin updates
2019-10-14 01:40:34,558 - iotccsdk - INFO - frame_iterators - start:184 - result_src: rtsp://192.168.72.18:8902/live
2019-10-14 01:40:34,579 - iotccsdk - INFO - frame_iterators - start:185 - gstreamer cmd: gst-launch-1.0  -q  rtspsrc  location=rtsp://192.168.72.18:8902/live protocols=tcp  !  application/x-rtp, media=application  !  fakesink  dump=true
2019-10-14 01:40:34,580 - iotccsdk - INFO - frame_iterators - start:188 - Platform: linux
[PKS INFO] Checking if result object is a person
[PKS INFO] Confirmed - object is a person!
[PKS INFO] existing snapshots: 0
[PKS INFO] snapshots have been deleted, new count: 0
[PKS INFO] Attempting camera capture...
2019-10-14 01:40:37,193 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.18:1080/captureimage data {}
Received twin callback
Received twin update: {'reported': {'SupportedEncodingTypes': 'HEVC/H.265 | AVC/H.264', 'SupportedConfigOverlayStyles': 'text | inference', 'ShowVideoPreview': True, 'HdmiDisplayActive': True, 'SupportedResolutions': '4K | 1080P | 720P | 480P', 'SupportedFrameRates': '24 | 30', 'Resolution': '1080P', 'VideoOverlayConfig': 'inference', '$version': 236, 'VideoAnalyticsEnabled': True, 'ModelZipUrl': '', 'TimeBetweenMessagesInSeconds': 12, 'Codec': 'AVC/H.264', 'ObjectsOfInterest': '["ALL"]', 'FrameRate': 30, 'ShowVideoOverlay': True, 'RtspVideoUrl': 'rtsp://192.168.72.18:8900/live', 'Bitrate': '1.5Mbps', 'RtspDataUrl': 'rtsp://192.168.72.18:8902/live', 'SupportedBitrates': '512Kbps | 768Kbps | 1Mbps | 1.5Mbps | 2Mbps | 3Mbps | 4Mbps | 6Mbps | 8Mbps | 10Mbps | 20Mbps'}, 'desired': {'TimeBetweenMessagesInSeconds': 12, 'ShowVideoPreview': True, 'ObjectsOfInterest': '["ALL"]', 'Resolution': '1080P', 'VideoOverlayConfig': 'inference', '$version': 3, 'HdmiDisplayActive': True, 'ModelZipUrl': '', 'Codec': 'AVC/H.264', 'VideoAnalyticsEnabled': True, 'FrameRate': 30, 'ShowVideoOverlay': True, 'Bitrate': '1.5Mbps'}}
Send prop: {"RtspVideoUrl": "rtsp://192.168.72.18:8900/live"}
Send prop: {"RtspDataUrl": "rtsp://192.168.72.18:8902/live"}
Send prop: {"Resolution": "1080P"}
Send prop: {"FrameRate": 30}
Send prop: {"Codec": "AVC/H.264"}
Send prop: {"VideoOverlayConfig": "inference"}
Send prop: {"Bitrate": "1.5Mbps"}
Send prop: {"VideoAnalyticsEnabled": true}
Send prop: {"HdmiDisplayActive": true}
Send prop: {"ShowVideoOverlay": true}
Send prop: {"ShowVideoPreview": true}
Send prop: {"SupportedBitrates": "512Kbps | 768Kbps | 1Mbps | 1.5Mbps | 2Mbps | 3Mbps | 4Mbps | 6Mbps | 8Mbps | 10Mbps | 20Mbps"}
Send prop: {"SupportedConfigOverlayStyles": "text | inference"}
Send prop: {"SupportedEncodingTypes": "HEVC/H.265 | AVC/H.264"}
Send prop: {"SupportedFrameRates": "24 | 30"}
Send prop: {"SupportedResolutions": "4K | 1080P | 720P | 480P"}
Send prop: {"ModelZipUrl": ""}
Send prop: {"TimeBetweenMessagesInSeconds": 12}
Send prop: {"ObjectsOfInterest": "[\"ALL\"]"}
Confirmation of 204 received for {"RtspVideoUrl": "rtsp://192.168.72.18:8900/live"}.
Confirmation of 204 received for {"RtspDataUrl": "rtsp://192.168.72.18:8902/live"}.
Confirmation of 204 received for {"Resolution": "1080P"}.
Confirmation of 204 received for {"FrameRate": 30}.
Confirmation of 204 received for {"Codec": "AVC/H.264"}.
Confirmation of 204 received for {"VideoOverlayConfig": "inference"}.
Confirmation of 204 received for {"Bitrate": "1.5Mbps"}.
Confirmation of 204 received for {"VideoAnalyticsEnabled": true}.
Confirmation of 204 received for {"HdmiDisplayActive": true}.
Confirmation of 204 received for {"ShowVideoOverlay": true}.
Confirmation of 204 received for {"ShowVideoPreview": true}.
Confirmation of 204 received for {"SupportedBitrates": "512Kbps | 768Kbps | 1Mbps | 1.5Mbps | 2Mbps | 3Mbps | 4Mbps | 6Mbps | 8Mbps | 10Mbps | 20Mbps"}.
Confirmation of 204 received for {"SupportedConfigOverlayStyles": "text | inference"}.
Confirmation of 204 received for {"SupportedEncodingTypes": "HEVC/H.265 | AVC/H.264"}.
Confirmation of 204 received for {"SupportedFrameRates": "24 | 30"}.
Confirmation of 204 received for {"SupportedResolutions": "4K | 1080P | 720P | 480P"}.
Confirmation of 204 received for {"ModelZipUrl": ""}.
Confirmation of 204 received for {"TimeBetweenMessagesInSeconds": 12}.
Confirmation of 204 received for {"ObjectsOfInterest": "[\"ALL\"]"}.
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.

We're looking for any insight into what could be causing this error and where to from here in terms of resolving this issue.

@PuneetRahejaMS
Copy link
Contributor

@sezflynn Thanks for p[ointing this. We are looking ito it and will get back soon.

@PuneetRahejaMS PuneetRahejaMS self-assigned this Oct 14, 2019
@PuneetRahejaMS PuneetRahejaMS added the SupportNeeded Help needed to get unblocked or to get an answer to a question label Oct 14, 2019
@PuneetRahejaMS PuneetRahejaMS added this to Triage Needed in VAIDK Issue Management via automation Oct 14, 2019
@sharminProvoke
Copy link

Hi @PuneetRahejaMS, do you have an update on this issue?

@PuneetRahejaMS
Copy link
Contributor

Hi @sezflynn, @sharminProvoke,

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.

@jkubicka jkubicka moved this from Triage Needed to Support Requests in VAIDK Issue Management Oct 22, 2019
@sezflynn
Copy link
Author

So I added some code to make sure the camera was running and an initial snapshot was successful before progressing to the rest of the logic. I placed a piece of white paper in front of the camera and uploaded the new container; it still errors:

while True:
        with create_camera() as camera_client:
            try:
                ipc_provider = camera_client.ipc_provider
                camera_props.configure_camera_client(camera_client)
                iot_hub_manager = IotHubManager(
                    protocol, camera_client, properties)
                iot_hub_manager.subscribe_to_events()
// NEW CODE HERE:
                camera_running = False
                camera_success = False
                while not camera_running:
                    print("[PKS INFO] Waiting for camera...")
                    if camera_client.vam_running:
                        print("[PKS INFO] Camera running, initial snapshot")
                        camera_running = True
                        try:
                            camera_client.captureimage()
                            camera_success = True
                        except Exception:
                            camera_success = False

                if camera_success:
// RETURN TO ORIGINAL CODE FROM HERE:
                    person_detected = False
                    while True:
                        try:
                            while camera_client.vam_running and not person_detected:
                                with camera_client.get_inferences() as results:
                                    for result in results:
                                        if is_person(result, last_time):
                                            print("[PKS INFO] Confirmed - object is a person!")
                                            person_detected = True
                                            azure_face_api_detect(camera_client, iot_hub_manager)
                                            # face_api_thread = threading.Thread(
                                            #     target=azure_face_api_detect,
                                            #     args=(camera_client, iot_hub_manager))
                                            # face_api_thread.start()
                                        last_time = print_inference(
                                            result, iot_hub_manager, last_time)
                        except EOFError:
                            print("EOFError. Current VAM running state is %s." %
                                camera_client.vam_running)
                       // etc....

The container cycles through the same set of errors about 7 times, with this extra error on the 6th and 7th tries:

urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.72.7', port=1080): Max retries exceeded with url: /vam (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xb5408eb0>: Failed to establish a new connection: [Errno 111] Connection refused',))

First log:

C:\Users\sezf
> adb shell                                                                                                                                                                                                / # docker ps -a
CONTAINER ID        IMAGE                                                       COMMAND                   CREATED             STATUS                       PORTS                                                                  NAMES
c885cfe6cf35        pksiotpocreg.azurecr.io/pksaivision:0.2.6_debug-4-arm32v7   "python3 -u ./main.py"    12 minutes ago      Exited (255) 2 minutes ago                                                                          PksSmartVisionModule
668f73c0c2ad        pksiotpocreg.azurecr.io/webstreammodule:0.0.20-arm32v7      "docker-entrypoint.s…"    6 days ago          Up About an hour                                                                                    WebStreamModule
97f071b0ff20        mcr.microsoft.com/azureiotedge-hub:1.0                      "/bin/sh -c 'echo \"$…"   6 days ago          Up 6 minutes                 0.0.0.0:443->443/tcp, 0.0.0.0:5671->5671/tcp, 0.0.0.0:8883->8883/tcp   edgeHub
7e7a5195b3e6        mcr.microsoft.com/azureiotedge-agent:1.0                    "/bin/sh -c 'echo \"$…"   6 days ago          Up About an hour                                                                                    edgeAgent
/ # docker logs c885cfe6cf35
Create model_util
Create properties
Init Properties
Init CameraProperties
Init ModelProperties
Model already present and force update set to false

Python 3.5.2 (default, Jul 10 2019, 11:58:48)
[GCC 5.4.0 20160609]

Found IP: 192.168.72.7
ip address = 192.168.72.7
Create camera with no ipc_provider
2019-10-22 23:29:04,074 - iotccsdk - INFO - ipcprovider - connect:264 - API: http://192.168.72.7:1080/login data: {'username': 'admin', 'userpwd': 'admin'}
2019-10-22 23:29:04,234 - iotccsdk - INFO - ipcprovider - connect:266 - Login response: {"status":true}
2019-10-22 23:29:04,235 - iotccsdk - INFO - ipcprovider - connect:271 - connection established with session token: [session=b9eb44afa8]
2019-10-22 23:29:04,235 - iotccsdk - INFO - ipcprovider - __init__:326 - Connecting to: ws://192.168.72.7:1080/async
2019-10-22 23:29:04,238 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/video data {}
--- request header ---
GET /async HTTP/1.1
Upgrade: websocket
Connection: Upgrade
Host: 192.168.72.7:1080
Origin: http://192.168.72.7:1080
Sec-WebSocket-Key: SldmgzMR8WtM0/+R13qO9Q==
Sec-WebSocket-Version: 13


-----------------------
--- response header ---
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
2019-10-22 23:29:04,253 - iotccsdk - INFO - camera - _get_supported_params:313 - resolutions: ['4K', '1080P', '720P', '480P']
2019-10-22 23:29:04,255 - iotccsdk - INFO - camera - _get_supported_params:314 - encodetype: ['HEVC/H.265', 'AVC/H.264']
Connection: Upgrade
2019-10-22 23:29:04,258 - iotccsdk - INFO - camera - _get_supported_params:315 - bitrates: ['512Kbps', '768Kbps', '1Mbps', '1.5Mbps', '2Mbps', '3Mbps', '4Mbps', '6Mbps', '8Mbps', '10Mbps', '20Mbps']
2019-10-22 23:29:04,259 - iotccsdk - INFO - camera - _get_supported_params:316 - framerates: [24, 30]
2019-10-22 23:29:04,260 - iotccsdk - INFO - camera - _get_supported_params:318 - Current preview settings:
Sec-WebSocket-Accept: DZMmoguhflAPbmbQxBgFT7Dg7V0=
-----------------------
2019-10-22 23:29:04,261 - iotccsdk - INFO - camera - _get_supported_params:319 - resolution: 1080P
2019-10-22 23:29:04,262 - iotccsdk - INFO - camera - _get_supported_params:320 - encodetype: AVC/H.264
2019-10-22 23:29:04,280 - iotccsdk - INFO - camera - _get_supported_params:321 - bitrate: 1.5Mbps
2019-10-22 23:29:04,281 - iotccsdk - INFO - camera - _get_supported_params:322 - framerate: 30
2019-10-22 23:29:04,281 - iotccsdk - INFO - camera - _get_supported_params:323 - display_out: 1
Configuring camera_client
2019-10-22 23:29:04,281 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/overlay data {'switchStatus': False}
2019-10-22 23:29:04,263 - iotccsdk - INFO - ipcprovider - on_open:347 - Starting heartbeat...
Turning analytics off
Turning preview off
2019-10-22 23:29:04,292 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/preview data {'switchStatus': False}
2019-10-22 23:29:04,301 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/preview data {}
2019-10-22 23:29:04,313 - iotccsdk - INFO - camera - _get_preview_info:382 - preview url: None
Configure preview (1080P, AVC/H.264, 1.5Mbps, 30, 1)
2019-10-22 23:29:04,314 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/video data {'resolutionSelectVal': 1, 'bitRateSelectVal': 3, 'fpsSelectVal': 1, 'encodeModeSelectVal': 1, 'displayOut': 1}
set preview state: on
2019-10-22 23:29:04,333 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/preview data {'switchStatus': True}
2019-10-22 23:29:05,100 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/preview data {}
2019-10-22 23:29:05,140 - iotccsdk - INFO - camera - _get_preview_info:382 - preview url: rtsp://192.168.72.7:8900/live
configure_overlay: inference
2019-10-22 23:29:05,142 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/overlayconfig data {'ov_color': '869007615', 'ov_width': 0, 'ov_start_y': 0, 'ov_type_SelectVal': 5, 'ov_position_SelectVal': 0, 'ov_height': 0, 'ov_usertext': 'Text', 'ov_start_x': 0}
configure_overlay_state: on
2019-10-22 23:29:05,205 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/overlay data {'switchStatus': True}
set_analytics_state: on
2019-10-22 23:29:05,226 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/vam data {'switchStatus': True, 'vamconfig': 'MD'}
2019-10-22 23:29:07,012 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/vam data {}
2019-10-22 23:29:07,030 - iotccsdk - INFO - camera - _get_vam_info:431 - RESPONSE: {'url': 'rtsp://192.168.72.7:8902/live', 'md_port': '', 'fr_port': '', 'ct_port': '', 'status': True}:
2019-10-22 23:29:07,031 - iotccsdk - INFO - camera - _get_vam_info:444 - vam url: rtsp://192.168.72.7:8902/live
Creating IoT Hub manager
Subscribing to method calls
Subscribing to module twin updates
[PKS INFO] Waiting for camera...
[PKS INFO] Camera running, initial snapshot
2019-10-22 23:29:07,431 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/captureimage data {}
Received twin callback
Received twin update: {'desired': {'TimeBetweenMessagesInSeconds': 12, 'ModelZipUrl': '', '$version': 14, 'Bitrate': '1.5Mbps', 'Resolution': '1080P', 'FrameRate': 30, 'HdmiDisplayActive': True, 'ObjectsOfInterest': '["ALL"]', 'VideoAnalyticsEnabled': True, 'ShowVideoOverlay': True, 'ShowVideoPreview': True, 'Codec': 'AVC/H.264', 'VideoOverlayConfig': 'inference'}, 'reported': {'SupportedEncodingTypes': 'HEVC/H.265 | AVC/H.264', 'SupportedFrameRates': '24 | 30', 'VideoOverlayConfig': 'inference', 'Codec': 'AVC/H.264', '$version': 6821, 'RtspDataUrl': 'rtsp://192.168.72.7:8902/live', 'Bitrate': '1.5Mbps', 'ObjectsOfInterest': '["ALL"]', 'RtspVideoUrl': 'rtsp://192.168.72.7:8900/live', 'FrameRate': 30, 'TimeBetweenMessagesInSeconds': 12, 'HdmiDisplayActive': True, 'Resolution': '1080P', 'VideoAnalyticsEnabled': True, 'ShowVideoOverlay': True, 'ShowVideoPreview': True, 'SupportedResolutions': '4K | 1080P | 720P | 480P', 'SupportedBitrates': '512Kbps | 768Kbps | 1Mbps | 1.5Mbps | 2Mbps | 3Mbps | 4Mbps | 6Mbps | 8Mbps | 10Mbps | 20Mbps', 'SupportedConfigOverlayStyles': 'text | inference', 'ModelZipUrl': ''}}
Send prop: {"Bitrate": "1.5Mbps"}
Send prop: {"FrameRate": 30}
Send prop: {"RtspVideoUrl": "rtsp://192.168.72.7:8900/live"}
Send prop: {"Codec": "AVC/H.264"}
Send prop: {"RtspDataUrl": "rtsp://192.168.72.7:8902/live"}
Send prop: {"Resolution": "1080P"}
Send prop: {"VideoOverlayConfig": "inference"}
Send prop: {"VideoAnalyticsEnabled": true}
Send prop: {"HdmiDisplayActive": true}
Send prop: {"ShowVideoOverlay": true}
Send prop: {"ShowVideoPreview": true}
Send prop: {"SupportedBitrates": "512Kbps | 768Kbps | 1Mbps | 1.5Mbps | 2Mbps | 3Mbps | 4Mbps | 6Mbps | 8Mbps | 10Mbps | 20Mbps"}
Send prop: {"SupportedConfigOverlayStyles": "text | inference"}
Send prop: {"SupportedEncodingTypes": "HEVC/H.265 | AVC/H.264"}
Send prop: {"SupportedFrameRates": "24 | 30"}
Send prop: {"SupportedResolutions": "4K | 1080P | 720P | 480P"}
Send prop: {"ModelZipUrl": ""}
Send prop: {"TimeBetweenMessagesInSeconds": 12}
Send prop: {"ObjectsOfInterest": "[\"ALL\"]"}
Confirmation of 204 received for {"Bitrate": "1.5Mbps"}.
Confirmation of 204 received for {"FrameRate": 30}.
Confirmation of 204 received for {"RtspVideoUrl": "rtsp://192.168.72.7:8900/live"}.
Confirmation of 204 received for {"Codec": "AVC/H.264"}.
Confirmation of 204 received for {"RtspDataUrl": "rtsp://192.168.72.7:8902/live"}.
Confirmation of 204 received for {"Resolution": "1080P"}.
Confirmation of 204 received for {"VideoOverlayConfig": "inference"}.
Confirmation of 204 received for {"VideoAnalyticsEnabled": true}.
Confirmation of 204 received for {"HdmiDisplayActive": true}.
Confirmation of 204 received for {"ShowVideoOverlay": true}.
Confirmation of 204 received for {"ShowVideoPreview": true}.
Confirmation of 204 received for {"SupportedBitrates": "512Kbps | 768Kbps | 1Mbps | 1.5Mbps | 2Mbps | 3Mbps | 4Mbps | 6Mbps | 8Mbps | 10Mbps | 20Mbps"}.
Confirmation of 204 received for {"SupportedConfigOverlayStyles": "text | inference"}.
Confirmation of 204 received for {"SupportedEncodingTypes": "HEVC/H.265 | AVC/H.264"}.
Confirmation of 204 received for {"SupportedFrameRates": "24 | 30"}.
Confirmation of 204 received for {"SupportedResolutions": "4K | 1080P | 720P | 480P"}.
Confirmation of 204 received for {"ModelZipUrl": ""}.
Confirmation of 204 received for {"TimeBetweenMessagesInSeconds": 12}.
Confirmation of 204 received for {"ObjectsOfInterest": "[\"ALL\"]"}.
2019-10-22 23:29:12,478 - iotccsdk - ERROR - camera - captureimage:602 - true
2019-10-22 23:29:12,481 - iotccsdk - INFO - frame_iterators - start:184 - result_src: rtsp://192.168.72.7:8902/live
2019-10-22 23:29:12,482 - iotccsdk - INFO - frame_iterators - start:185 - gstreamer cmd: gst-launch-1.0  -q  rtspsrc  location=rtsp://192.168.72.7:8902/live protocols=tcp  !  application/x-rtp, media=application  !  fakesink  dump=true
2019-10-22 23:29:12,484 - iotccsdk - INFO - frame_iterators - start:188 - Platform: linux
2019-10-22 23:29:13,991 - iotccsdk - ERROR - ipcprovider - on_error:341 - Camera Restarted! Exiting!!

Last log:

2019-10-22 23:35:23,791 - iotccsdk - ERROR - ipcprovider - on_error:341 - Camera Restarted! Exiting!!
Create model_util
Create properties
Init Properties
Init CameraProperties
Init ModelProperties
Model already present and force update set to false

Python 3.5.2 (default, Jul 10 2019, 11:58:48)
[GCC 5.4.0 20160609]

Found IP: 192.168.72.7
ip address = 192.168.72.7
Create camera with no ipc_provider
2019-10-22 23:38:08,926 - iotccsdk - INFO - ipcprovider - connect:264 - API: http://192.168.72.7:1080/login data: {'userpwd': 'admin', 'username': 'admin'}
2019-10-22 23:38:13,404 - iotccsdk - INFO - ipcprovider - connect:266 - Login response: {"status":true}
2019-10-22 23:38:13,407 - iotccsdk - INFO - ipcprovider - connect:271 - connection established with session token: [session=dc3167a5322]
2019-10-22 23:38:13,408 - iotccsdk - INFO - ipcprovider - __init__:326 - Connecting to: ws://192.168.72.7:1080/async
2019-10-22 23:38:13,411 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/video data {}
--- request header ---
GET /async HTTP/1.1
Upgrade: websocket
Connection: Upgrade
Host: 192.168.72.7:1080
Origin: http://192.168.72.7:1080
Sec-WebSocket-Key: Bk/M1d+ruqVkwFJaGUXWrA==
Sec-WebSocket-Version: 13


-----------------------
--- response header ---
2019-10-22 23:38:13,423 - iotccsdk - INFO - camera - _get_supported_params:313 - resolutions: ['4K', '1080P', '720P', '480P']
2019-10-22 23:38:13,424 - iotccsdk - INFO - camera - _get_supported_params:314 - encodetype: ['HEVC/H.265', 'AVC/H.264']
HTTP/1.1 101 Switching Protocols
2019-10-22 23:38:13,424 - iotccsdk - INFO - camera - _get_supported_params:315 - bitrates: ['512Kbps', '768Kbps', '1Mbps', '1.5Mbps', '2Mbps', '3Mbps', '4Mbps', '6Mbps', '8Mbps', '10Mbps', '20Mbps']
2019-10-22 23:38:13,426 - iotccsdk - INFO - camera - _get_supported_params:316 - framerates: [24, 30]
2019-10-22 23:38:13,427 - iotccsdk - INFO - camera - _get_supported_params:318 - Current preview settings:
Upgrade: websocket
2019-10-22 23:38:13,427 - iotccsdk - INFO - camera - _get_supported_params:319 - resolution: 1080P
2019-10-22 23:38:13,429 - iotccsdk - INFO - camera - _get_supported_params:320 - encodetype: AVC/H.264
2019-10-22 23:38:13,429 - iotccsdk - INFO - camera - _get_supported_params:321 - bitrate: 1.5Mbps
2019-10-22 23:38:13,430 - iotccsdk - INFO - camera - _get_supported_params:322 - framerate: 30
2019-10-22 23:38:13,430 - iotccsdk - INFO - camera - _get_supported_params:323 - display_out: 1
Configuring camera_client
2019-10-22 23:38:13,431 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/overlay data {'switchStatus': False}
Connection: Upgrade
Sec-WebSocket-Accept: qe0b5+8GdKRstGtNqkdXJcy/5yA=
-----------------------
Turning analytics off
Turning preview off
2019-10-22 23:38:13,443 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/preview data {'switchStatus': False}
2019-10-22 23:38:13,444 - iotccsdk - INFO - ipcprovider - on_open:347 - Starting heartbeat...
2019-10-22 23:38:13,456 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/preview data {}
2019-10-22 23:38:13,466 - iotccsdk - INFO - camera - _get_preview_info:382 - preview url: None
Configure preview (1080P, AVC/H.264, 1.5Mbps, 30, 1)
2019-10-22 23:38:13,467 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/video data {'resolutionSelectVal': 1, 'fpsSelectVal': 1, 'displayOut': 1, 'encodeModeSelectVal': 1, 'bitRateSelectVal': 3}
set preview state: on
2019-10-22 23:38:13,484 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/preview data {'switchStatus': True}
2019-10-22 23:38:14,890 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/preview data {}
2019-10-22 23:38:14,953 - iotccsdk - INFO - camera - _get_preview_info:382 - preview url: rtsp://192.168.72.7:8900/live
configure_overlay: inference
2019-10-22 23:38:14,954 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/overlayconfig data {'ov_width': 0, 'ov_height': 0, 'ov_position_SelectVal': 0, 'ov_start_y': 0, 'ov_type_SelectVal': 5, 'ov_start_x': 0, 'ov_color': '869007615', 'ov_usertext': 'Text'}
configure_overlay_state: on
2019-10-22 23:38:15,061 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/overlay data {'switchStatus': True}
set_analytics_state: on
2019-10-22 23:38:15,155 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/vam data {'vamconfig': 'MD', 'switchStatus': True}
2019-10-22 23:38:21,847 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/vam data {}
2019-10-22 23:38:21,884 - iotccsdk - ERROR - ipcprovider - on_error:341 - Camera Restarted! Exiting!!
2019-10-22 23:38:22,310 - iotccsdk - ERROR - ipcprovider - __send_request:231 - HTTPConnectionPool(host='192.168.72.7', port=1080): Max retries exceeded with url: /vam (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xb5408eb0>: Failed to establish a new connection: [Errno 111] Connection refused',))
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/urllib3/connection.py", line 157, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/usr/local/lib/python3.5/dist-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/usr/local/lib/python3.5/dist-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 387, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.5/http/client.py", line 1122, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python3.5/http/client.py", line 1167, in _send_request
    self.endheaders(body)
  File "/usr/lib/python3.5/http/client.py", line 1118, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python3.5/http/client.py", line 944, in _send_output
    self.send(msg)
  File "/usr/lib/python3.5/http/client.py", line 887, in send
    self.connect()
  File "/usr/local/lib/python3.5/dist-packages/urllib3/connection.py", line 184, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.5/dist-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0xb5408eb0>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/usr/local/lib/python3.5/dist-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.72.7', port=1080): Max retries exceeded with url: /vam (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xb5408eb0>: Failed to establish a new connection: [Errno 111] Connection refused',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/iotccsdk/ipcprovider.py", line 220, in __send_request
    url, data=json.dumps(payload), headers=headers, params=params)
  File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 546, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.72.7', port=1080): Max retries exceeded with url: /vam (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xb5408eb0>: Failed to establish a new connection: [Errno 111] Connection refused',))
Try to clean up before the end
2019-10-22 23:38:22,688 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/overlay data {'switchStatus': False}
2019-10-22 23:38:22,768 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/vam data {'vamconfig': 'MD', 'switchStatus': False}
2019-10-22 23:38:22,784 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://192.168.72.7:1080/vam data {}
/ # 

@sezflynn
Copy link
Author

Okay, a couple of reboots seems to have cleared the above problems, camera is taking snapshots now!

@sezflynn
Copy link
Author

We're getting snapshots and successfully passing them to azure face api. Thank you for your help @PuneetRahejaMS

VAIDK Issue Management automation moved this from Support Requests to Closed Oct 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
SupportNeeded Help needed to get unblocked or to get an answer to a question
Projects
Development

No branches or pull requests

3 participants