google-coral / project-posenet

Human Pose Detection on EdgeTPU
Apache License 2.0
549 stars 156 forks source link

default pose model crashing #83

Open ilonadem opened 2 years ago

ilonadem commented 2 years ago

Description

Hi, I am trying to run pose_camera.py with a USB camera and it is crashing at variable times (sometimes it takes 10 minutes and sometimes it takes 10seconds). The only thing I've changed are the frame rate and the resolution (because of the camera specs), but I don't know how to fix this issue because the whole camera display shuts down and I am taken back to the login screen again.

Click to expand! ### Issue Type Bug, Build/Install, Performance, Support ### Operating System Mac OS ### Coral Device Dev Board ### Other Devices USB Camera ### Programming Language Python 3.7 ### Relevant Log Output ```shell (base) ilonademler@dhcp-10-250-96-201 research % screen /dev/cu.SLAB_USBtoUART12 115200 [ 8.129147] uvcvideo 1-1:1.0: Entity type for entity Processing 2 was not initialized! [ 8.139966] hif_pci_probe:, con_mode= 0x0 [ 8.151941] uvcvideo 1-1:1.0: Entity type for entity Camera 1 was not initialized! [ 8.160297] PCI device id is 003e :003e [ 8.169820] input: Web Camera: Web Camera as /devices/platform/usb@38200000/38200000.dwc3/xhci-hcd.0.auto/usb1/1-1/1-1:1.0/input/input2 [ 8.179359] hif_pci 0000:01:00.0: BAR 0: assigned [mem 0x18000000-0x181fffff 64bit] [ 8.193407] usbcore: registered new interface driver uvcvideo [ 8.194394] Galcore version 6.4.2.256507 [ 8.207467] hif_pci 0000:01:00.0: enabling device (0000 -> 0002) [ 8.215057] USB Video Class driver (1.1.1) [ 8.224894] [ 8.224894] hif_pci_configure : num_desired MSI set to 1 [ 8.311038] usbcore: registered new interface driver snd-usb-audio [ 8.525411] EXT4-fs (mmcblk0p3): mounted filesystem with ordered data mode. Opts: (null) [ 8.780736] hif_pci_probe: ramdump base 0xffff800025200000 size 2095136 [ 8.804759] NUM_DEV=1 FWMODE=0x2 FWSUBMODE=0x0 FWBR_BUF 0 [ 9.350869] using random self ethernet address [ 9.359101] using random host ethernet address [ 9.375278] using random self ethernet address [ 9.375282] using random host ethernet address [ 9.430579] random: crng init done [ 9.439097] random: 7 urandom warning(s) missed due to ratelimiting [ 9.552120] +HWT [ 9.564714] -HWT [ 9.589378] HTT: full reorder offload enabled [ 9.619672] Pkt log is disabled [ 9.626741] target uses HTT version 3.50; host uses 3.28 [ 9.631186] Host SW:4.5.23.1, FW:2.0.1.1048, HW:QCA6174_REV3_2 [ 9.648167] ol_pktlog_init: pktlogmod_init successfull [ 9.648499] wlan: driver loaded in 1528000 [ 9.798817] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready [ 9.810871] Generic PHY 30be0000.ethernet-1:00: attached PHY driver [Generic PHY] (mii_bus:phy_addr=30be0000.ethernet-1:00, irq=POLL) [ 9.827350] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready [ 9.869982] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready [ 9.870458] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready [ 9.970243] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready [ 10.407770] usb0: HOST MAC f2:7c:56:aa:d7:74 [ 10.422973] usb0: MAC 02:22:78:0d:f6:df [ 10.433342] usb1: HOST MAC 02:22:78:0d:f6:dd [ 10.442665] usb1: MAC 02:22:78:0d:f6:de [ 10.664243] IPv6: ADDRCONF(NETDEV_UP): usb0: link is not ready [ 10.675725] IPv6: ADDRCONF(NETDEV_UP): usb0: link is not ready [ 10.690799] IPv6: ADDRCONF(NETDEV_UP): usb0: link is not ready [ 10.708845] IPv6: ADDRCONF(NETDEV_UP): usb0: link is not ready [ 10.942321] IPv6: ADDRCONF(NETDEV_UP): usb1: link is not ready [ 10.953887] IPv6: ADDRCONF(NETDEV_UP): usb1: link is not ready [ 10.969870] IPv6: ADDRCONF(NETDEV_UP): usb1: link is not ready [ 10.980110] IPv6: ADDRCONF(NETDEV_UP): usb1: link is not ready [ 11.736712] i.mx8-hdp 32c00000.hdmi: 0,ff,ff,ff,ff,ff,ff,0 Mendel GNU/Linux (eagle) undefined-calf ttymxc0 undefined-calf login: [ 13.133234] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready [ 22.725226] [drm] HDMI/DP Cable Plug Out ```
hjonnala commented 2 years ago

Hi, have you tried with any other frame rate and the resolution? Can you please share the frame rate and resolution you are using and the output of below command. Thanks!

v4l2-ctl --list-formats-ext --device /dev/video1

ilonadem commented 2 years ago

Running the command gives:

Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 1440x1080
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 1920x1080
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
        [2]: 'YUYV' (YUYV 4:2:2)
                Size: Discrete 320x240
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 480x272
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 640x360
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 640x480
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 800x600
                        Interval: Discrete 0.067s (15.000 fps)
                Size: Discrete 1024x576
                        Interval: Discrete 0.100s (10.000 fps)
                Size: Discrete 1280x720
                        Interval: Discrete 0.100s (10.000 fps)

and this is how I've implemented it in the file:

def main():
    n = 0
    sum_process_time = 0
    sum_inference_time = 0
    ctr = 0
    fps_counter = avg_fps_counter(30)

    def run_inference(engine, input_tensor):
        return engine.run_inference(input_tensor)

    def render_overlay(engine, output, src_size, inference_box):
        nonlocal n, sum_process_time, sum_inference_time, fps_counter

        svg_canvas = svgwrite.Drawing('', size=src_size)
        start_time = time.monotonic()
        outputs, inference_time = engine.ParseOutput()
        end_time = time.monotonic()
        n += 1
        sum_process_time += 1000 * (end_time - start_time)
        sum_inference_time += inference_time * 1000

        avg_inference_time = sum_inference_time / n
        text_line = 'PoseNet: %.1fms (%.2f fps) TrueFPS: %.2f Nposes %d' % (
            avg_inference_time, 1000 / avg_inference_time, next(fps_counter), len(outputs)
        )

        shadow_text(svg_canvas, 10, 20, text_line)
        for pose in outputs:
            draw_pose(svg_canvas, pose, src_size, inference_box)
        return (svg_canvas.tostring(), False)

    run(run_inference, render_overlay)

if __name__ == '__main__':
    main()
hjonnala commented 2 years ago

The only thing I've changed are the frame rate and the resolution (because of the camera specs)

Can you please share the frame rate and the resolution you are using. Thanks!

ilonadem commented 2 years ago

Using a frame rate of 30 and resolution of 640 x 480

hjonnala commented 2 years ago

Seems to be you are using the default values. It should be working fine, not sure why it is not working for you. Have you tried examples-camera repo examples and are you experiencing the same behavior?