Git Product home page Git Product logo

Comments (20)

jkubicka avatar jkubicka commented on August 10, 2024

@MKaandorp

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.

from vision-ai-developer-kit.

MKaandorp avatar MKaandorp commented on August 10, 2024

@jkubicka, thanks for the quick response.

In my solution I make use of an image classification model, which classifies an image as either an object if the image contains an object, or as "Negative" if the image does not contain an object. This means that there is no way for me to prevent the triggering of inference, as covering the camera lens will result in a "Negative" classification.

However, if I understand correctly, the work-around provided by @sezflynn should make sure an initial snapshot is taken before the camera starts detecting inferences (or at least before camera_client.get_inferences() is called). Therefore, this should have the same effect as covering the camera lens while the module starts.

Both work-arounds do not work for me. 9 out of 10 times, the module reports iotccsdk - ERROR - camera - captureimage:602 - true and crashes.

Do you know of any other way to force the camera to take a snapshot before it starts detecting inferences?

from vision-ai-developer-kit.

jkubicka avatar jkubicka commented on August 10, 2024

Duplicate of #251

from vision-ai-developer-kit.

jkubicka avatar jkubicka commented on August 10, 2024

@MKaandorp Try the following workaround, it may make the error occur less often:

CameraClientWorkaround

from vision-ai-developer-kit.

MKaandorp avatar MKaandorp commented on August 10, 2024

@jkubicka, thanks for the response and the provided work-around. It seems similar to this work-around provided by @sezflyyn.

Unfortunately, this does not solve the problem for me. I tried it multiple times, but keep getting the same errors as before, after which the module crashes. The logs are provided below.

I suspect this work-around will work as well as the one provide by @sezflynn I mentioned earlier. That is to say, the module does not crash on startup once every 10-20 tries. However, a more reliable fix would be appreciated.

I have not yet been able to find a pattern as to why it sometimes does not crash. Maybe by chance the timing at which the snapshot is taken is sometimes just right? Do you have any ideas?

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, Oct  8 2019, 13:06:37)
[GCC 5.4.0 20160609]

lets go
Found IP: XXX.XXX.XX.XXX
ip address = XXX.XXX.XX.XXX
Create camera with no ipc_provider
2019-10-29 09:15:23,899 - iotccsdk - INFO - ipcprovider - connect:264 - API: http://XXX.XXX.XX.XXX:1080/login data: {'username': 'admin', 'userpwd': 'admin'}
2019-10-29 09:15:23,980 - iotccsdk - INFO - ipcprovider - connect:266 - Login response: {"status":true}
2019-10-29 09:15:23,981 - iotccsdk - INFO - ipcprovider - connect:271 - connection established with session token: [session=1df92fefa3]
2019-10-29 09:15:23,982 - iotccsdk - INFO - ipcprovider - __init__:326 - Connecting to: ws://XXX.XXX.XX.XXX:1080/async
2019-10-29 09:15:23,985 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/video data {}
--- request header ---
GET /async HTTP/1.1
Upgrade: websocket
Connection: Upgrade
Host: XXX.XXX.XX.XXX:1080
Origin: http://XXX.XXX.XX.XXX:1080
Sec-WebSocket-Key: NqHcS/p6vrSkoPMxLDcUcQ==
Sec-WebSocket-Version: 13


-----------------------
--- response header ---
HTTP/1.1 101 Switching Protocols
2019-10-29 09:15:23,998 - iotccsdk - INFO - ipcprovider - on_open:347 - Starting heartbeat...
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: RqsrMazKZoC0PyWTrK/EwcOPQfA=
-----------------------
2019-10-29 09:15:24,003 - iotccsdk - INFO - camera - _get_supported_params:313 - resolutions: ['4K', '1080P', '720P', '480P']
2019-10-29 09:15:24,005 - iotccsdk - INFO - camera - _get_supported_params:314 - encodetype: ['HEVC/H.265', 'AVC/H.264']
2019-10-29 09:15:24,005 - iotccsdk - INFO - camera - _get_supported_params:315 - bitrates: ['512Kbps', '768Kbps', '1Mbps', '1.5Mbps', '2Mbps', '3Mbps', '4Mbps', '6Mbps', '8Mbps', '10Mbps', '20Mbps']
2019-10-29 09:15:24,006 - iotccsdk - INFO - camera - _get_supported_params:316 - framerates: [24, 30]
2019-10-29 09:15:24,006 - iotccsdk - INFO - camera - _get_supported_params:318 - Current preview settings:
2019-10-29 09:15:24,007 - iotccsdk - INFO - camera - _get_supported_params:319 - resolution: 1080P
2019-10-29 09:15:24,007 - iotccsdk - INFO - camera - _get_supported_params:320 - encodetype: AVC/H.264
2019-10-29 09:15:24,008 - iotccsdk - INFO - camera - _get_supported_params:321 - bitrate: 1.5Mbps
2019-10-29 09:15:24,008 - iotccsdk - INFO - camera - _get_supported_params:322 - framerate: 30
2019-10-29 09:15:24,008 - iotccsdk - INFO - camera - _get_supported_params:323 - display_out: 1
Configuring camera_client
2019-10-29 09:15:24,009 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/overlay data {'switchStatus': False}
Turning analytics off
Turning preview off
2019-10-29 09:15:24,020 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/preview data {'switchStatus': False}
2019-10-29 09:15:24,030 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/preview data {}
2019-10-29 09:15:24,040 - iotccsdk - INFO - camera - _get_preview_info:382 - preview url: None
Configure preview (1080P, AVC/H.264, 1.5Mbps, 30, 1)
2019-10-29 09:15:24,041 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/video data {'resolutionSelectVal': 1, 'fpsSelectVal': 1, 'bitRateSelectVal': 3, 'displayOut': 1, 'encodeModeSelectVal': 1}
set preview state: on
2019-10-29 09:15:24,058 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/preview data {'switchStatus': True}
2019-10-29 09:15:24,855 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/preview data {}
2019-10-29 09:15:24,936 - iotccsdk - INFO - camera - _get_preview_info:382 - preview url: rtsp://XXX.XXX.XX.XXX:8900/live
configure_overlay: inference
2019-10-29 09:15:24,944 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/overlayconfig data {'ov_type_SelectVal': 5, 'ov_width': 0, 'ov_usertext': 'Text', 'ov_position_SelectVal': 0, 'ov_height': 0, 'ov_start_x': 0, 'ov_color': '869007615', 'ov_start_y': 0}
configure_overlay_state: on
2019-10-29 09:15:24,971 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/overlay data {'switchStatus': True}
set_analytics_state: on
2019-10-29 09:15:25,013 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/vam data {'switchStatus': True, 'vamconfig': 'MD'}
2019-10-29 09:15:28,276 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/vam data {}
2019-10-29 09:15:28,376 - iotccsdk - INFO - camera - _get_vam_info:431 - RESPONSE: {'ct_port': '', 'url': 'rtsp://XXX.XXX.XX.XXX:8902/live', 'fr_port': '', 'status': True, 'md_port': ''}:
2019-10-29 09:15:28,377 - iotccsdk - INFO - camera - _get_vam_info:444 - vam url: rtsp://XXX.XXX.XX.XXX:8902/live
Creating IoT Hub manager
Subscribing to method calls
Subscribing to module twin updates
2019-10-29 09:15:28,800 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/captureimage data {}
Received twin callback
Received twin update: {'reported': {'Bitrate': '1.5Mbps', 'SupportedFrameRates': '24 | 30', 'HdmiDisplayActive': True, 'TimeBetweenMessagesInSeconds': 12, 'ShowVideoOverlay': True, 'ModelZipUrl': '', 'SupportedConfigOverlayStyles': 'text | inference', 'Codec': 'AVC/H.264', 'SupportedBitrates': '512Kbps | 768Kbps | 1Mbps | 1.5Mbps | 2Mbps | 3Mbps | 4Mbps | 6Mbps | 8Mbps | 10Mbps | 20Mbps', 'FrameRate': 30, '$version': 533, 'SupportedEncodingTypes': 'HEVC/H.265 | AVC/H.264', 'ObjectsOfInterest': '["ALL"]', 'SupportedResolutions': '4K | 1080P | 720P | 480P', 'VideoAnalyticsEnabled': True, 'VideoOverlayConfig': 'inference', 'ShowVideoPreview': True, 'RtspVideoUrl': 'rtsp://XXX.XXX.XX.XXX:8900/live', 'Resolution': '1080P', 'RtspDataUrl': 'rtsp://XXX.XXX.XX.XXX:8902/live'}, 'desired': {'Bitrate': '1.5Mbps', 'HdmiDisplayActive': True, 'TimeBetweenMessagesInSeconds': 12, 'ShowVideoOverlay': True, 'ModelZipUrl': '', 'VideoOverlayConfig': 'inference', 'FrameRate': 30, 'ObjectsOfInterest': '["ALL"]', '$version': 208, 'VideoAnalyticsEnabled': True, 'Codec': 'AVC/H.264', 'ShowVideoPreview': True, 'Resolution': '1080P'}}
Send prop: {"VideoOverlayConfig": "inference"}
Send prop: {"Resolution": "1080P"}
Send prop: {"FrameRate": 30}
Send prop: {"Codec": "AVC/H.264"}
Send prop: {"RtspVideoUrl": "rtsp://XXX.XXX.XX.XXX:8900/live"}
Send prop: {"RtspDataUrl": "rtsp://XXX.XXX.XX.XXX:8902/live"}
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 {"VideoOverlayConfig": "inference"}.
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 {"RtspVideoUrl": "rtsp://XXX.XXX.XX.XXX:8900/live"}.
Confirmation of 204 received for {"RtspDataUrl": "rtsp://XXX.XXX.XX.XXX:8902/live"}.
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\"]"}.
2019-10-29 09:15:34,409 - iotccsdk - ERROR - camera - captureimage:602 - true
start inferences
2019-10-29 09:15:34,524 - iotccsdk - INFO - frame_iterators - start:184 - result_src: rtsp://XXX.XXX.XX.XXX:8902/live
2019-10-29 09:15:34,525 - iotccsdk - INFO - frame_iterators - start:185 - gstreamer cmd: gst-launch-1.0  -q  rtspsrc  location=rtsp://XXX.XXX.XX.XXX:8902/live protocols=tcp  !  application/x-rtp, media=application  !  fakesink  dump=true
2019-10-29 09:15:34,525 - iotccsdk - INFO - frame_iterators - start:188 - Platform: linux
send: b'\x89\x80\xd2A\xe7\xa1'
start inferences
2019-10-29 09:15:35,675 - iotccsdk - INFO - frame_iterators - start:184 - result_src: rtsp://XXX.XXX.XX.XXX:8902/live
2019-10-29 09:15:35,676 - iotccsdk - INFO - frame_iterators - start:185 - gstreamer cmd: gst-launch-1.0  -q  rtspsrc  location=rtsp://XXX.XXX.XX.XXX:8902/live protocols=tcp  !  application/x-rtp, media=application  !  fakesink  dump=true
2019-10-29 09:15:35,677 - iotccsdk - INFO - frame_iterators - start:188 - Platform: linux
start inferences
2019-10-29 09:15:35,829 - iotccsdk - INFO - frame_iterators - start:184 - result_src: rtsp://XXX.XXX.XX.XXX:8902/live
2019-10-29 09:15:35,831 - iotccsdk - INFO - frame_iterators - start:185 - gstreamer cmd: gst-launch-1.0  -q  rtspsrc  location=rtsp://XXX.XXX.XX.XXX:8902/live protocols=tcp  !  application/x-rtp, media=application  !  fakesink  dump=true
2019-10-29 09:15:35,832 - iotccsdk - INFO - frame_iterators - start:188 - Platform: linux
start inferences
2019-10-29 09:15:35,951 - iotccsdk - INFO - frame_iterators - start:184 - result_src: rtsp://XXX.XXX.XX.XXX:8902/live
2019-10-29 09:15:35,953 - iotccsdk - INFO - frame_iterators - start:185 - gstreamer cmd: gst-launch-1.0  -q  rtspsrc  location=rtsp://XXX.XXX.XX.XXX:8902/live protocols=tcp  !  application/x-rtp, media=application  !  fakesink  dump=true
2019-10-29 09:15:35,955 - iotccsdk - INFO - frame_iterators - start:188 - Platform: linux
start inferences
2019-10-29 09:15:36,212 - iotccsdk - INFO - frame_iterators - start:184 - result_src: rtsp://XXX.XXX.XX.XXX:8902/live
2019-10-29 09:15:36,262 - iotccsdk - INFO - frame_iterators - start:185 - gstreamer cmd: gst-launch-1.0  -q  rtspsrc  location=rtsp://XXX.XXX.XX.XXX:8902/live protocols=tcp  !  application/x-rtp, media=application  !  fakesink  dump=true
2019-10-29 09:15:36,263 - iotccsdk - ERROR - ipcprovider - on_error:341 - Camera Restarted! Exiting!!
2019-10-29 09:15:36,264 - iotccsdk - INFO - frame_iterators - start:188 - Platform: linux
start inferences
2019-10-29 09:15:36,329 - iotccsdk - INFO - frame_iterators - start:184 - result_src: rtsp://XXX.XXX.XX.XXX:8902/live
2019-10-29 09:15:36,330 - iotccsdk - INFO - frame_iterators - start:185 - gstreamer cmd: gst-launch-1.0  -q  rtspsrc  location=rtsp://XXX.XXX.XX.XXX:8902/live protocols=tcp  !  application/x-rtp, media=application  !  fakesink  dump=true
2019-10-29 09:15:36,331 - iotccsdk - INFO - frame_iterators - start:188 - Platform: linux
start inferences
2019-10-29 09:15:36,411 - iotccsdk - INFO - frame_iterators - start:184 - result_src: rtsp://XXX.XXX.XX.XXX:8902/live
2019-10-29 09:15:36,412 - iotccsdk - INFO - frame_iterators - start:185 - gstreamer cmd: gst-launch-1.0  -q  rtspsrc  location=rtsp://XXX.XXX.XX.XXX:8902/live protocols=tcp  !  application/x-rtp, media=application  !  fakesink  dump=true
2019-10-29 09:15:36,413 - iotccsdk - INFO - frame_iterators - start:188 - Platform: linux
start inferences
2019-10-29 09:15:36,492 - iotccsdk - INFO - frame_iterators - start:184 - result_src: rtsp://XXX.XXX.XX.XXX:8902/live
2019-10-29 09:15:36,493 - iotccsdk - INFO - frame_iterators - start:185 - gstreamer cmd: gst-launch-1.0  -q  rtspsrc  location=rtsp://XXX.XXX.XX.XXX:8902/live protocols=tcp  !  application/x-rtp, media=application  !  fakesink  dump=true
2019-10-29 09:15:36,495 - iotccsdk - INFO - frame_iterators - start:188 - Platform: linux
start inferences
2019-10-29 09:15:36,589 - iotccsdk - INFO - frame_iterators - start:184 - result_src: rtsp://XXX.XXX.XX.XXX:8902/live
2019-10-29 09:15:36,590 - iotccsdk - INFO - frame_iterators - start:185 - gstreamer cmd: gst-launch-1.0  -q  rtspsrc  location=rtsp://XXX.XXX.XX.XXX:8902/live protocols=tcp  !  application/x-rtp, media=application  !  fakesink  dump=true
2019-10-29 09:15:36,591 - iotccsdk - INFO - frame_iterators - start:188 - Platform: linux

from vision-ai-developer-kit.

jkubicka avatar jkubicka commented on August 10, 2024

@MKaandorp

We're looking into a bug fix for this one - stay tuned!

I'll get back to you on a possible workaround.

from vision-ai-developer-kit.

jkubicka avatar jkubicka commented on August 10, 2024

@MKaandorp Can you please provide sample code so we can repro and look into further?

from vision-ai-developer-kit.

MKaandorp avatar MKaandorp commented on August 10, 2024

@jkubicka No problem, you can find the code below. Please note that I make use of image classification in my project.

This code is based on the code in the face detect sample, and the workaround suggested by @sezflynn.

I believe all relevant code is there, the problem occurs anytime camera_client.captureimage() is called.

# Captures an image and uploads it to Azure
def get_and_send_image(img_name):
    print("lets capture image")
    remove_old_snapshots(dir_name, file_name)
    camera_client.captureimage()
    print("img captured")
    try:
        print("start uploading to azure")
        block_blob_service = BlockBlobService(
            account_name=storage_account_name, account_key=storage_account_key)
        print("block blob service created")
        this_img_name = get_snapshot_name()
        print(this_img_name)
        block_blob_service.create_blob_from_path(
            az_anomaly_folder, img_name, this_img_name)
        print("captured and uploaded!")
    except:
        print("unable to upload file to azure")


# Checks if anomaly is detected, and triggers corresponding action
def anomaly_detector():
    global label_queue
    global anomaly_found
    global no_anomaly_labels
    global anomaly_labels
    if not anomaly_found:
        for this_label in anomaly_labels:
            # Certain anomaly is found if >75% of values in queue correspnd to anomaly
            if(label_queue.count(this_label) > (0.75 * label_queue.maxlen)):
                print("anomaly detected!")
                img_name_local = time.strftime('%Y%m%d%H%M%S') + ".jpg"
                get_and_send_image(img_name_local)
                img_name = az_anomaly_url + img_name_local
                print(img_name)
                # Send label of anomaly + url to image to upstream
                json_dict = {"anomaly": this_label, "imgurl": img_name}
                json_message = json.dumps(json_dict)
                iot_hub_manager.send_message_to_upstream(json_message)
                anomaly_found = True
                break
    # If anomaly is already detected, wait for situation to go back to normal before triggering new actions
    elif anomaly_found:
        for this_label in no_anomaly_labels:
            if(label_queue.count(this_label) > 0.75 * label_queue.maxlen):
                anomaly_found = False
                break


def main(protocol):
    global ipc_provider
    global camera_client
    global iot_hub_manager
    global properties
    global model_util
    global first_pic_taken

    print("Create model_util")
    model_util = ModelUtility()

    print("Create properties")
    properties = Properties()
    camera_props = properties.camera_properties

    # push model
    model_util.transfer_dlc(False)

    print("\nPython %s\n" % sys.version)
    last_time = time.time()

    while True:
        with create_camera() as camera_client:
            try:
                ipc_provider = camera_client.ipc_provider
                camera_props.configure_camera_client(camera_client)

                camera_success = False
                first_run = True
                while not camera_success:
                    if(first_run):
                        print("[PKS INFO] Waiting for camera...")
                        first_run = False
                    if camera_client.vam_running:
                        print("[PKS INFO] Camera running, initial snapshot")
                        try:
                            camera_client.captureimage()
                            camera_success = True
                        except Exception:
                            camera_success = False

                if camera_success:
                    iot_hub_manager = IotHubManager(
                        protocol, camera_client, properties)
                    iot_hub_manager.subscribe_to_events()
                    while True:
                        try:
                            while camera_client.vam_running:
                                print("start inferences")
                                with camera_client.get_inferences() as results:
                                    for result in results:
                                        last_time = print_inference(
                                            result, iot_hub_manager, last_time)
                                        # Add label of inference to queue
                                        add_label_to_queue(result)
                                        # Check if anomaly is detected
                                        anomaly_detector()
                        except EOFError:
                            print("EOFError. Current VAM running state is %s." %
                                  camera_client.vam_running)
                        except Exception:
                            log_unknown_exception(
                                "Exception from get inferences", iot_hub_manager)
                            continue

            except CameraClientError as cce:
                print("Received camera error, but will try to continue: %s" % cce)
                if camera_client is not None:
                    status = camera_client.logout()
                    print("Logout with status: %s" % status)
                camera_client = None
                continue
            except IoTHubError as iothub_error:
                print("Unexpected error %s from IoTHub" % iothub_error)
                return
            except KeyboardInterrupt:
                print("IoTHubModuleClient sample stopped")
                return
            finally:
                print("Try to clean up before the end")
                if camera_client is not None:
                    camera_client.set_overlay_state(SETTING_OFF)
                    camera_client.set_analytics_state(SETTING_OFF)
                    camera_client.set_preview_state(SETTING_OFF)
                    status = camera_client.logout()
                    print("Logout with status: %s" % status)

from vision-ai-developer-kit.

jkubicka avatar jkubicka commented on August 10, 2024

@MKaandorp We'll need “add_label_to_queue()” function to run the code for a repro…

cameraclientcrash1

You can test now to see if it improves stability is passing the camera_client and iot_hub_manager to their functions calling the “camera_client.captureimage()” and “iot_hub_manager.send_message_to_upstream()”

Given the way the code flows, try to first pass it to “anomaly_detector()” then “get_and_send_image(img_name):”

Try to update like this:

cameraclientcrash2

cameraclientcrash3

cameraclientcrash4

from vision-ai-developer-kit.

MKaandorp avatar MKaandorp commented on August 10, 2024

@jkubicka Thanks for the response.

Below is all code in the file, which should allow you to reproduce the problem.

Passing camera_client and iot_hub_manager to the functions instead of using global variables does not seem to make a difference.

import sys
if __package__ == '' or __package__ is None:  # noqa
    import os
    parent_dir = os.path.dirname(
        os.path.dirname(os.path.abspath(__file__)))
    sys.path.insert(1, parent_dir)
    pkg_name = os.path.split(os.path.dirname(os.path.abspath(__file__)))[-1]
    __import__(pkg_name)
    __package__ = str(pkg_name)

from . constants import SETTING_OFF
from . error_utils import CameraClientError, log_unknown_exception
from . properties import Properties
from . model_utility import ModelUtility
from . inference import Inference
from . iot_hub_manager import IotHubManager
from iotccsdk import CameraClient
from iothub_client import IoTHubTransportProvider, IoTHubError
import time
from collections import deque
import json

from pathlib import Path
from azure.storage.blob import BlockBlobService


# Choose HTTP, AMQP or MQTT as transport protocol.  Currently only MQTT is supported.
IOT_HUB_PROTOCOL = IoTHubTransportProvider.MQTT

ipc_provider = None
camera_client = None
iot_hub_manager = None
properties = None
model_util = None
label_queue = deque([], 120)
anomaly_found = False
first_pic_taken = False

# Labels that should or should not trigger a response
no_anomaly_labels = ['label1', 'Negative']
anomaly_labels = ['label2']

# Folder on Azure in which pics of anomaly should be stored
az_anomaly_url = 'XXX'
storage_account_name = 'XXX'
storage_account_key = 'XXX'
az_anomaly_folder = 'XXX'


dir_name = os.path.dirname(os.path.abspath(__name__))
file_name = "*napshot*.jpg"
remove_file_name = "*napshot*.jpg"

def create_camera(ip_address=None, username="admin", password="admin"):
    if ip_address is None:
        ip_address = model_util.getWlanIp()

    print("ip address = %s" % ip_address)
    if ipc_provider is None:
        print("Create camera with no ipc_provider")
        return CameraClient.connect(
            ip_address=ip_address,
            username=username,
            password=password)

    print("Create camera with ipc_provider %s" % ipc_provider)
    return CameraClient.connect(
        ipc_provider=ipc_provider,
        ip_address=ip_address,
        username=username,
        password=password)


def print_inference(result=None, hub_manager=None, last_sent_time=time.time()):
    global properties
    global label_queue
    if (time.time() - last_sent_time <= properties.model_properties.message_delay_sec
            or result is None
            or result.objects is None
            or len(result.objects) == 0):
        return last_sent_time

    for inf_obj in result.objects:
        print("Found result object")
        inference = Inference(inf_obj)
        if (properties.model_properties.is_object_of_interest(inference.label)):
            json_message = inference.to_json()
            print(json_message)
            last_sent_time = time.time()
    return last_sent_time


def remove_old_snapshots(dir_name, remove_file_name):
    snapshot_files = list(Path(dir_name).glob("**/%s" % remove_file_name))
    for file in snapshot_files:
        str_file = str(file)
        os.chmod(str_file, 0o777)
        os.remove(str_file)


# Returns the filename of the taken snapshot
def get_snapshot_name(file_name=file_name):
    print("lets get snapshot name")
    print(dir_name)
    selected_files = list(Path(dir_name).glob("**/%s" % file_name))
    print(selected_files)
    print(Path(dir_name))
    foldercontent = os.listdir(dir_name)
    for x in foldercontent:
        print(x)

    if len(selected_files) != 1:
        print("Expected 1 file but got %s" %
              (selected_files))
        return

    str_file = str(selected_files[0])
    print(str_file)
    os.chmod(str_file, 0o777)
    return str_file


# Adds current label to queue
def add_label_to_queue(result):
    global label_queue
    if(result.objects):
        label_queue.append(Inference(result.objects[0]).label)


# Captures an image and uploads it to Azure
def get_and_send_image(img_name):
    print("lets capture image")
    remove_old_snapshots(dir_name, file_name)
    camera_client.captureimage()
    print("img captured")
    try:
        print("start uploading to azure")
        block_blob_service = BlockBlobService(
            account_name=storage_account_name, account_key=storage_account_key)
        print("block blob service created")
        this_img_name = get_snapshot_name()
        print(this_img_name)
        block_blob_service.create_blob_from_path(
            az_anomaly_folder, img_name, this_img_name)
        print("captured and uploaded!")
    except:
        print("unable to upload file to azure")


# Checks if anomaly is detected, and triggers corresponding action
def anomaly_detector():
    global label_queue
    global anomaly_found
    global no_anomaly_labels
    global anomaly_labels
    if not anomaly_found:
        for this_label in anomaly_labels:
            # Certain anomaly is found if >75% of values in queue correspnd to anomaly
            if(label_queue.count(this_label) > (0.75 * label_queue.maxlen)):
                print("anomaly detected!")
                img_name_local = time.strftime('%Y%m%d%H%M%S') + ".jpg"
                get_and_send_image(img_name_local)
                img_name = az_anomaly_url + img_name_local
                print(img_name)
                # Send label of anomaly + url to image to upstream
                json_dict = {"anomaly": this_label, "imgurl": img_name}
                json_message = json.dumps(json_dict)
                iot_hub_manager.send_message_to_upstream(json_message)
                anomaly_found = True
                break
    # If anomaly is already detected, wait for situation to go back to normal before triggering new actions
    elif anomaly_found:
        for this_label in no_anomaly_labels:
            if(label_queue.count(this_label) > 0.75 * label_queue.maxlen):
                anomaly_found = False
                break


def main(protocol):
    global ipc_provider
    global camera_client
    global iot_hub_manager
    global properties
    global model_util
    global first_pic_taken

    print("Create model_util")
    model_util = ModelUtility()

    print("Create properties")
    properties = Properties()
    camera_props = properties.camera_properties

    # push model
    model_util.transfer_dlc(False)

    print("\nPython %s\n" % sys.version)
    last_time = time.time()

    while True:
        with create_camera() as camera_client:
            try:
                ipc_provider = camera_client.ipc_provider
                camera_props.configure_camera_client(camera_client)

                camera_success = False
                first_run = True
                while not camera_success:
                    if(first_run):
                        print("[PKS INFO] Waiting for camera...")
                        first_run = False
                    if camera_client.vam_running:
                        print("[PKS INFO] Camera running, initial snapshot")
                        try:
                            camera_client.captureimage()
                            camera_success = True
                        except Exception:
                            camera_success = False

                if camera_success:
                    iot_hub_manager = IotHubManager(
                        protocol, camera_client, properties)
                    iot_hub_manager.subscribe_to_events()
                    while True:
                        try:
                            while camera_client.vam_running:
                                print("start inferences")
                                with camera_client.get_inferences() as results:
                                    for result in results:
                                        last_time = print_inference(
                                            result, iot_hub_manager, last_time)
                                        # Add label of inference to queue
                                        add_label_to_queue(result)
                                        # Check if anomaly is detected
                                        anomaly_detector()
                        except EOFError:
                            print("EOFError. Current VAM running state is %s." %
                                  camera_client.vam_running)
                        except Exception:
                            log_unknown_exception(
                                "Exception from get inferences", iot_hub_manager)
                            continue

            except CameraClientError as cce:
                print("Received camera error, but will try to continue: %s" % cce)
                if camera_client is not None:
                    status = camera_client.logout()
                    print("Logout with status: %s" % status)
                camera_client = None
                continue
            except IoTHubError as iothub_error:
                print("Unexpected error %s from IoTHub" % iothub_error)
                return
            except KeyboardInterrupt:
                print("IoTHubModuleClient sample stopped")
                return
            finally:
                print("Try to clean up before the end")
                if camera_client is not None:
                    camera_client.set_overlay_state(SETTING_OFF)
                    camera_client.set_analytics_state(SETTING_OFF)
                    camera_client.set_preview_state(SETTING_OFF)
                    status = camera_client.logout()
                    print("Logout with status: %s" % status)

from vision-ai-developer-kit.

jkubicka avatar jkubicka commented on August 10, 2024

@MKaandorp Please see if this sample code works:

Copyright (c) Microsoft. All rights reserved.

Licensed under the MIT license. See LICENSE file in the project root for

full license information.

import sys
if package == '' or package is None: # noqa
import os
parent_dir = os.path.dirname(
os.path.dirname(os.path.abspath(file)))
sys.path.insert(1, parent_dir)
pkg_name = os.path.split(os.path.dirname(os.path.abspath(file)))[-1]
import(pkg_name)
package = str(pkg_name)
del os
from . constants import SETTING_OFF
from . error_utils import CameraClientError, log_unknown_exception
from . properties import Properties
from . model_utility import ModelUtility
from . inference import Inference
from . iot_hub_manager import IotHubManager
from iotccsdk import CameraClient
from iothub_client import IoTHubTransportProvider, IoTHubError
import time
import subprocess
import os
import threading
from pathlib import Path
from . azure_face_api import azure_face_api_detect, remove_old_snapshots, get_snapshot_name
import json
from collections import deque
from pathlib import Path

from azure.storage.blob import BlockBlobService

Choose HTTP, AMQP or MQTT as transport protocol. Currently only MQTT is supported.

IOT_HUB_PROTOCOL = IoTHubTransportProvider.MQTT

ipc_provider = None
camera_client = None
iot_hub_manager = None
properties = None
model_util = None
label_queue = deque([], 120)
anomaly_found = False
first_pic_taken = False

Folder on Azure in which pics of anomaly should be stored

az_anomaly_url = 'XXX'
storage_account_name = 'XXX'
storage_account_key = 'XXX'
az_anomaly_folder = 'XXX'

def create_camera(ip_address=None, username="admin", password="admin"):
if ip_address is None:
ip_address = model_util.getWlanIp()

print("ip address = %s" % ip_address)
if ipc_provider is None:
    print("Create camera with no ipc_provider")
    return CameraClient.connect(
        ip_address=ip_address,
        username=username,
        password=password)

print("Create camera with ipc_provider %s" % ipc_provider)
return CameraClient.connect(
    ipc_provider=ipc_provider,
    ip_address=ip_address,
    username=username,
    password=password)

def print_inference(result=None, hub_manager=None, last_sent_time=time.time()):
global properties
if (time.time() - last_sent_time <= properties.model_properties.message_delay_sec
or result is None
or result.objects is None
or len(result.objects) == 0):
return last_sent_time

for inf_obj in result.objects:
    print("Found result object")
    inference = Inference(inf_obj)
    if (properties.model_properties.is_object_of_interest(inference.label)):
        json_message = inference.to_json()
        iot_hub_manager.send_message_to_upstream(json_message)
        print(json_message)
        last_sent_time = time.time()
return last_sent_time

def is_person(result=None, last_sent_time=time.time()):
global properties
if (time.time() - last_sent_time <= properties.model_properties.message_delay_sec
or result is None
or result.objects is None
or len(result.objects) == 0):
return False

for inf_obj in result.objects:
    print("Found result object")
    inference = Inference(inf_obj)
    if (inference.label == 'person' or inference.label == 'person.'):
        return True
return False

Adds current label to queue

def add_label_to_queue(result):
global label_queue
if(result.objects):
label_queue.append(Inference(result.objects[0]).label)
# print(str(label_queue))

dir_name = os.path.dirname(os.path.abspath(name))
file_name = "qmmf_snapshot*.jpg"

remove_file_name_type1 = "snapshot*.jpg"

remove_file_name_type2 = "qmmf_snapshot*.jpg"

remove_file_name = "napshot.jpg"

Captures an image and uploads it to Azure

def get_and_send_image(img_name):
print("lets capture image")
remove_old_snapshots(dir_name, file_name)
camera_client.captureimage()
print("img captured")
try:
print("start uploading to azure")
# block_blob_service = BlockBlobService(
# account_name=storage_account_name, account_key=storage_account_key)
print("block blob service created")
this_img_name = get_snapshot_name()
print(this_img_name)
# block_blob_service.create_blob_from_path(
# az_anomaly_folder, img_name, this_img_name)
print("captured and uploaded!")
except:
print("unable to upload file to azure")

no_anomaly_labels = ["tv"]
anomaly_labels = ["person"]

Checks if anomaly is detected, and triggers corresponding action

def anomaly_detector():
global label_queue
global anomaly_found
global no_anomaly_labels
global anomaly_labels
if not anomaly_found:
for this_label in anomaly_labels:
# print("anomaly_labels: " + this_label)
# Certain anomaly is found if >75% of values in queue correspnd to anomaly
if(label_queue.count(this_label) > (0.75 * label_queue.maxlen)):
print("anomaly detected!")
img_name_local = time.strftime('%Y%m%d%H%M%S') + ".jpg"
get_and_send_image(img_name_local)
img_name = az_anomaly_url + img_name_local
print(img_name)
# Send label of anomaly + url to image to upstream
json_dict = {"anomaly": this_label, "imgurl": img_name}
json_message = json.dumps(json_dict)
iot_hub_manager.send_message_to_upstream(json_message)
anomaly_found = True
break
# If anomaly is already detected, wait for situation to go back to normal before triggering new actions
elif anomaly_found:
for this_label in no_anomaly_labels:
# print("no_anomaly_labels: " + this_label)
if(label_queue.count(this_label) > 0.75 * label_queue.maxlen):
anomaly_found = False
break

def main(protocol):
global ipc_provider
global camera_client
global iot_hub_manager
global properties
global model_util
global first_pic_taken

print("Create model_util")
model_util = ModelUtility()

print("Create properties")
properties = Properties()
camera_props = properties.camera_properties

# push model
model_util.transfer_dlc(False)

print("\nPython %s\n" % sys.version)
last_time = time.time()

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()
            if camera_client.vam_running:
                camera_client.captureimage()

            while True:
                try:
                    while camera_client.vam_running:
                            print("start inferences")
                            with camera_client.get_inferences() as results:
                                for result in results:
                                    last_time = print_inference(
                                        result, iot_hub_manager, last_time)
                                    # Add label of inference to queue
                                    add_label_to_queue(result)
                                    # Check if anomaly is detected
                                    anomaly_detector()
                except EOFError:
                    print("EOFError. Current VAM running state is %s." %
                          camera_client.vam_running)
                except Exception:
                    log_unknown_exception(
                        "Exception from get inferences", iot_hub_manager)
                    continue
        except CameraClientError as cce:
            print("Received camera error, but will try to continue: %s" % cce)
            if camera_client is not None:
                status = camera_client.logout()
                print("Logout with status: %s" % status)
            camera_client = None
            continue
        except IoTHubError as iothub_error:
            print("Unexpected error %s from IoTHub" % iothub_error)
            return
        except KeyboardInterrupt:
            print("IoTHubModuleClient sample stopped")
            return
        finally:
            print("Try to clean up before the end")
            if camera_client is not None:
                camera_client.set_overlay_state(SETTING_OFF)
                camera_client.set_analytics_state(SETTING_OFF)
                camera_client.set_preview_state(SETTING_OFF)
                status = camera_client.logout()
                print("Logout with status: %s" % status)

if name == 'main':
main(IOT_HUB_PROTOCOL)

from vision-ai-developer-kit.

jkubicka avatar jkubicka commented on August 10, 2024

The azure blob upload portions are commented out for testing snapshot only. It is set to use “tv” as non-anomaly and “person” as an anomaly. Point the camera at a computer monitor to have it detect “tv” to fill up the queue then point it back to a person to get an “anomoly” / initate a screen shot.

from vision-ai-developer-kit.

MKaandorp avatar MKaandorp commented on August 10, 2024

@jkubicka Thanks for the response.

Unfortunately, this does not seem to fix the issue. The module crashes on startup with the same error as before. The logs are added below.
Does this code work on your machine?
Also, it would be great if you could put your code in a codeblock next time.

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, Oct  8 2019, 13:06:37)
[GCC 5.4.0 20160609]

Found IP: XXX.XXX.XX.XXX
ip address = XXX.XXX.XX.XXX
Create camera with no ipc_provider
2019-11-08 15:47:20,514 - iotccsdk - INFO - ipcprovider - connect:264 - API: http://XXX.XXX.XX.XXX:1080/login data: {'userpwd': 'admin', 'username': 'admin'}
2019-11-08 15:47:21,691 - iotccsdk - INFO - ipcprovider - connect:266 - Login response: {"status":true}
2019-11-08 15:47:21,692 - iotccsdk - INFO - ipcprovider - connect:271 - connection established with session token: [session=736ee22b8a]
2019-11-08 15:47:21,693 - iotccsdk - INFO - ipcprovider - __init__:326 - Connecting to: ws://XXX.XXX.XX.XXX:1080/async
2019-11-08 15:47:21,696 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/video data {}
2019-11-08 15:47:21,709 - iotccsdk - INFO - ipcprovider - on_open:347 - Starting heartbeat...
--- request header ---
GET /async HTTP/1.1
Upgrade: websocket
Connection: Upgrade
Host: XXX.XXX.XX.XXX:1080
Origin: http://XXX.XXX.XX.XXX:1080
Sec-WebSocket-Key: XXX
Sec-WebSocket-Version: 13


-----------------------
--- response header ---
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: PT7MLKUX1xcpq/c90HWe5zmMUwU=
-----------------------
2019-11-08 15:47:21,716 - iotccsdk - INFO - camera - _get_supported_params:313 - resolutions: ['4K', '1080P', '720P', '480P']
2019-11-08 15:47:21,717 - iotccsdk - INFO - camera - _get_supported_params:314 - encodetype: ['HEVC/H.265', 'AVC/H.264']
2019-11-08 15:47:21,718 - iotccsdk - INFO - camera - _get_supported_params:315 - bitrates: ['512Kbps', '768Kbps', '1Mbps', '1.5Mbps', '2Mbps', '3Mbps', '4Mbps', '6Mbps', '8Mbps', '10Mbps', '20Mbps']
2019-11-08 15:47:21,718 - iotccsdk - INFO - camera - _get_supported_params:316 - framerates: [24, 30]
2019-11-08 15:47:21,718 - iotccsdk - INFO - camera - _get_supported_params:318 - Current preview settings:
2019-11-08 15:47:21,719 - iotccsdk - INFO - camera - _get_supported_params:319 - resolution: 1080P
2019-11-08 15:47:21,720 - iotccsdk - INFO - camera - _get_supported_params:320 - encodetype: AVC/H.264
2019-11-08 15:47:21,720 - iotccsdk - INFO - camera - _get_supported_params:321 - bitrate: 1.5Mbps
2019-11-08 15:47:21,721 - iotccsdk - INFO - camera - _get_supported_params:322 - framerate: 30
2019-11-08 15:47:21,721 - iotccsdk - INFO - camera - _get_supported_params:323 - display_out: 1
Configuring camera_client
2019-11-08 15:47:21,722 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/overlay data {'switchStatus': False}
Turning analytics off
Turning preview off
2019-11-08 15:47:21,733 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/preview data {'switchStatus': False}
2019-11-08 15:47:21,744 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/preview data {}
2019-11-08 15:47:21,754 - iotccsdk - INFO - camera - _get_preview_info:382 - preview url: None
Configure preview (1080P, AVC/H.264, 1.5Mbps, 30, 1)
2019-11-08 15:47:21,755 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/video data {'encodeModeSelectVal': 1, 'fpsSelectVal': 1, 'resolutionSelectVal': 1, 'displayOut': 1, 'bitRateSelectVal': 3}
set preview state: on
2019-11-08 15:47:21,773 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/preview data {'switchStatus': True}
2019-11-08 15:47:22,443 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/preview data {}
2019-11-08 15:47:22,471 - iotccsdk - INFO - camera - _get_preview_info:382 - preview url: rtsp://XXX.XXX.XX.XXX:8900/live
configure_overlay: inference
2019-11-08 15:47:22,474 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/overlayconfig data {'ov_usertext': 'Text', 'ov_start_y': 0, 'ov_type_SelectVal': 5, 'ov_width': 0, 'ov_start_x': 0, 'ov_position_SelectVal': 0, 'ov_color': '869007615', 'ov_height': 0}
configure_overlay_state: on
2019-11-08 15:47:22,494 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/overlay data {'switchStatus': True}
set_analytics_state: on
2019-11-08 15:47:22,509 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/vam data {'vamconfig': 'MD', 'switchStatus': True}
2019-11-08 15:47:23,364 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/vam data {}
2019-11-08 15:47:23,380 - iotccsdk - INFO - camera - _get_vam_info:431 - RESPONSE: {'fr_port': '', 'md_port': '', 'url': 'rtsp://XXX.XXX.XX.XXX:8902/live', 'status': True, 'ct_port': ''}:
2019-11-08 15:47:23,382 - iotccsdk - INFO - camera - _get_vam_info:444 - vam url: rtsp://XXX.XXX.XX.XXX:8902/live
Creating IoT Hub manager
Subscribing to method calls
Subscribing to module twin updates
2019-11-08 15:47:23,386 - iotccsdk - INFO - ipcprovider - __send_request:212 - API: http://XXX.XXX.XX.XXX:1080/captureimage data {}
Received twin callback
Received twin update: {'reported': {'VideoOverlayConfig': 'inference', 'ModelZipUrl': '', '$version': 556, 'TimeBetweenMessagesInSeconds': 12, 'SupportedBitrates': '512Kbps | 768Kbps | 1Mbps | 1.5Mbps | 2Mbps | 3Mbps | 4Mbps | 6Mbps | 8Mbps | 10Mbps | 20Mbps', 'SupportedEncodingTypes': 'HEVC/H.265 | AVC/H.264', 'SupportedFrameRates': '24 | 30', 'FrameRate': 30, 'VideoAnalyticsEnabled': True, 'RtspDataUrl': 'rtsp://XXX.XXX.XX.XXX:8902/live', 'ObjectsOfInterest': '["ALL"]', 'RtspVideoUrl': 'rtsp://XXX.XXX.XX.XXX:8900/live', 'Bitrate': '1.5Mbps', 'Codec': 'AVC/H.264', 'ShowVideoPreview': True, 'Resolution': '1080P', 'SupportedConfigOverlayStyles': 'text | inference', 'SupportedResolutions': '4K | 1080P | 720P | 480P', 'HdmiDisplayActive': True, 'ShowVideoOverlay': True}, 'desired': {'ModelZipUrl': '', 'VideoOverlayConfig': 'inference', '$version': 219, 'TimeBetweenMessagesInSeconds': 12, 'FrameRate': 30, 'VideoAnalyticsEnabled': True, 'ObjectsOfInterest': '["ALL"]', 'Bitrate': '1.5Mbps', 'Codec': 'AVC/H.264', 'ShowVideoPreview': True, 'Resolution': '1080P', 'ShowVideoOverlay': True, 'HdmiDisplayActive': True}}
Send prop: {"RtspVideoUrl": "rtsp://XXX.XXX.XX.XXX:8900/live"}
Send prop: {"Codec": "AVC/H.264"}
Send prop: {"VideoOverlayConfig": "inference"}
Send prop: {"Bitrate": "1.5Mbps"}
Send prop: {"Resolution": "1080P"}
Send prop: {"FrameRate": 30}
Send prop: {"RtspDataUrl": "rtsp://XXX.XXX.XX.XXX:8902/live"}
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://XXX.XXX.XX.XXX:8900/live"}.
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 {"Resolution": "1080P"}.
Confirmation of 204 received for {"FrameRate": 30}.
Confirmation of 204 received for {"RtspDataUrl": "rtsp://XXX.XXX.XX.XXX:8902/live"}.
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-11-08 15:47:28,419 - iotccsdk - ERROR - camera - captureimage:602 - true
start inferences
2019-11-08 15:47:28,423 - iotccsdk - INFO - frame_iterators - start:184 - result_src: rtsp://XXX.XXX.XX.XXX:8902/live
2019-11-08 15:47:28,425 - iotccsdk - INFO - frame_iterators - start:185 - gstreamer cmd: gst-launch-1.0  -q  rtspsrc  location=rtsp://XXX.XXX.XX.XXX:8902/live protocols=tcp  !  application/x-rtp, media=application  !  fakesink  dump=true
2019-11-08 15:47:28,426 - iotccsdk - INFO - frame_iterators - start:188 - Platform: linux
2019-11-08 15:47:29,114 - iotccsdk - ERROR - ipcprovider - on_error:341 - Camera Restarted! Exiting!!

from vision-ai-developer-kit.

jkubicka avatar jkubicka commented on August 10, 2024

@MKaandorp We're unable to repro the issue. What firmware are you running on the device?

from vision-ai-developer-kit.

jkubicka avatar jkubicka commented on August 10, 2024

@MKaandorp Any update? Are you still running into this issue?

from vision-ai-developer-kit.

MKaandorp avatar MKaandorp commented on August 10, 2024

@jkubicka Unfortunately, the issue is still there. I'm still running firmware v0.5280_Perf, which, I believe, is the most recent.

Due to the fact that you cannot reproduce the issue, could it be device specific? There are, however, some other people with similar issues #251 #258.

Are you sure the issue also doesn't happen for you when using image classification instead of object detection?

from vision-ai-developer-kit.

jkubicka avatar jkubicka commented on August 10, 2024

@MKaandorp Can you try testing at least one other code sample with screen capture?

If that still fails, then yes, this is more than likely a hardware issue. And in that case, a warranty replacement or return is the best route.

from vision-ai-developer-kit.

MKaandorp avatar MKaandorp commented on August 10, 2024

@jkubicka No problem, which code sample?

I finally got around to testing it on a different DevKit, and got the same result: the module still crashed when calling camera_client.captureimage(). I tested it with the same code I posted earlier, and the same image classification model I used earlier. This seems to suggest that it might not be a hardware issue.

from vision-ai-developer-kit.

jkubicka avatar jkubicka commented on August 10, 2024

@MKaandorp Try to swap out the main.py file in the FACEAPI code sample with the main.py we sent earlier on the new device. We got this code working.

from vision-ai-developer-kit.

jkubicka avatar jkubicka commented on August 10, 2024

@MKaandorp Closing issue. Please re-open if you're still not able to get other code samples from our repo working. Thanks.

from vision-ai-developer-kit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.