etiennedub / pyk4a

Python 3 wrapper for Azure-Kinect-Sensor-SDK
MIT License
287 stars 81 forks source link

Color camera not working with get_capture() in any configuration #185

Closed benpocklingtonhes closed 1 year ago

benpocklingtonhes commented 1 year ago

Hi, I am trying to get a minimal python script to run and simply record the Kinect DK output to an .mkv file. Here is the code that I am running :

from time import time
from pyk4a import *

DEVICE_ID = 0
FILE = '.\\results\\test.mkv'
CONFIG = Config(
    color_resolution=ColorResolution.RES_720P,
    color_format=ImageFormat.COLOR_BGRA32,
    depth_mode=DepthMode.WFOV_2X2BINNED,
    camera_fps=FPS.FPS_5,
    synchronized_images_only=False,
    depth_delay_off_color_usec=0,
    wired_sync_mode=WiredSyncMode.STANDALONE,
    subordinate_delay_off_master_usec=0,
    disable_streaming_indicator=False,
)

device = PyK4A(config=CONFIG, device_id=DEVICE_ID)
device.start()

record = PyK4ARecord(device=device, config=CONFIG, path=FILE)
record.create()

try:
    end = time() + 5
    while time() < end:
        capture = device.get_capture()
        record.write_capture(capture)
except KeyboardInterrupt:
    print('Recording was stopped. Saving file...')

record.flush()
record.close()

print(f"{record.captures_count} frames written.")
print("FINISHED!")

No matter what configuration I use (I think I have literally almost tried every single possible combination of parameters) the color camera drops 100% of frames, shown by this error (which is strangely marked as type:Depth, but does not occur with ColorResolution.OFF) :

[2022-12-12 16:34:08.413] [error] [t=5024] D:\a\1\s\extern\Azure-Kinect-Sensor-SDK\src\capturesync\capturesync.c (142): replace_sample(). capturesync_drop, releasing capture early due to full queue TS: 596044 type:Depth

If I set syncronized_images_only=True then because there are no Color frames, the .mvk contains nothing. I can however run the code with this set to False in order to get the .mvk with just the IR and Depth outputs. We have also tried this on multiple computers, multiple USB controllers, multiple cables etc. etc. which all yield the same results. Any ideas?

lpasselin commented 1 year ago

Have you tried the official viewer? What version of the SDK did you install? Did you install pyk4a with pyk4a-bundle? Did you try the example recording code directly? https://github.com/etiennedub/pyk4a/blob/master/example/record.py

benpocklingtonhes commented 1 year ago
benpocklingtonhes commented 1 year ago

Just a quick update : I tested the camera again with the unmodified recording example here - https://github.com/etiennedub/pyk4a/blob/master/example/record.py and I am still getting the same error as in my original issue. Let me know if you have any ideas...

lpasselin commented 1 year ago

@shagren any ideas?

shagren commented 1 year ago
  1. Please try to use synchronized_images_only=True,
  2. It can be windows usb controller problem. Only Intel, TI and NES(Renesas) chipsets are supported. Can you try to run on other desktop/laptop? Changing USB port/cable also can helps in some cases. Record example works for me on two different windows desktops and linux laptop
benpocklingtonhes commented 1 year ago
  1. Please try to use synchronized_images_only=True,
  2. It can be windows usb controller problem. Only Intel, TI and NES(Renesas) chipsets are supported. Can you try to run on other desktop/laptop? Changing USB port/cable also can helps in some cases. Record example works for me on two different windows desktops and linux laptop

Thanks for the ideas!

lpasselin commented 1 year ago

Also make sure the gpu drivers of your machines are up to date. I had a weird bug on a microsoft surface laptop a few years ago. It was caused by out of date gpu drivers. Unfortunately in my case the official viewer and recorder weren't working properly.

benpocklingtonhes commented 1 year ago

So for two weeks I have been trying to get this package working on my home computer with Windows 11. It will just not work, I've tried everything. I have every error under the sun that is associated with installing this package, no solutions work. I have been trying to use this package for work and I have nothing but constant problems.

shagren commented 1 year ago

@benpocklingtonhes , what about other examples:

https://github.com/etiennedub/pyk4a/blob/master/example/viewer.py https://github.com/etiennedub/pyk4a/blob/master/example/viewer_depth.py https://github.com/etiennedub/pyk4a/blob/master/example/viewer_transformation.py

shagren commented 1 year ago

BTW, i didn't test with win11, but all examples works for me with win10

benpocklingtonhes commented 1 year ago

@benpocklingtonhes , what about other examples:

https://github.com/etiennedub/pyk4a/blob/master/example/viewer.py https://github.com/etiennedub/pyk4a/blob/master/example/viewer_depth.py https://github.com/etiennedub/pyk4a/blob/master/example/viewer_transformation.py

I don't think you understand, I wasn't very clear haha, I cannot even install the pyK4a package on Windows 11 into a fresh venv, I have literally tried every fix, command, hack on the internet.

benpocklingtonhes commented 1 year ago

The first error I encountered on Windows 11 is fixed in PR #193