Coder Social home page Coder Social logo

Comments (3)

brendandburns avatar brendandburns commented on July 19, 2024

@amy-caali

Any chance you can send these as a PR (Pull Request) instead of an attachment?

If you've never sent a pull request before, there are pretty good instructions here:

https://thenewstack.io/getting-legit-with-git-and-github-your-first-pull-request/

Please let me know if you have any questions. I'd love to collaborate further!

Thanks!

from py-k4a.

amy-caali avatar amy-caali commented on July 19, 2024

Done! Here is more detail on the errors I'm still getting too.

Describe the bug
When using the device (having transferred from an older Dell PC to a new Lenovo PC), I am getting these errors (that I wasn't getting on the older Dell).

[2019-10-06 18:56:48.692] [error] [t=2352] D:\a\1\s\extern\Azure-Kinect-Sensor-SDK\src\image\image.c (51): k4a_image_t_get_context(). Invalid k4a_image_t 04AC6DE0
[2019-10-06 18:56:48.692] [error] [t=2352] D:\a\1\s\extern\Azure-Kinect-Sensor-SDK\src\image\image.c (333): Invalid argument to image_dec_ref(). image_handle (04AC6DE0) is not a valid handle of type k4a_image_t

To Reproduce
When I run

import k4a
import faulthandler

faulthandler.enable()

dev = k4a.Device()
if k4a.device_open(0, dev):
serial = k4a.device_get_serialnum(dev)
version = k4a.device_get_version(dev)
print("Opened device {} {}\n".format(serial, version))

config = k4a.DeviceConfiguration()
config.color_format = k4a.K4A_IMAGE_FORMAT_COLOR_MJPG
config.color_resolution = k4a.K4A_COLOR_RESOLUTION_2160P
config.depth_mode = k4a.K4A_DEPTH_MODE_NFOV_UNBINNED
config.camera_fps = k4a.K4A_FRAMES_PER_SECOND_30
config.synchronized_images_only = True

if k4a.device_start_cameras(dev, config):
    capture = k4a.Capture()
    res = k4a.device_get_capture(dev, capture, 1000)
    if res == k4a.K4A_WAIT_RESULT_SUCCEEDED:
        img = k4a.capture_get_color_image(capture)
        if img:
            w = k4a.image_get_width_pixels(img)
            h = k4a.image_get_height_pixels(img)
            s = k4a.image_get_stride_bytes(img)
            print('Capture: {} x {} @ {}'.format(h, w, s / w))

            try:
                with open('test.jpg', 'wb') as fp:
                    fp.write(k4a.image_get_buffer(img))
                    #k4a.image_release(img)
                    fp.flush()
                    fp.close()
            except:
                import sys
                print("Unexpected error:", sys.exc_info()[0])
        else:
            print('get image failed!')
    else:
        print('Capture failed!')
else:
    print("Failed to start cameras!")

k4a.device_stop_cameras(dev)
k4a.device_close(dev)
print("Closed")

else:
print("Failed to open device")

I usually but not always get

C:\Users\amy\caaliMICRO5\py-k4a>python example.py
Opened device 000666392412 (('rgb', (1, 6, 102)), ('depth', (1, 6, 75)), ('audio', (1, 6, 14)), ('depth_sensor', (6109, 7, 0)))

Capture: 2160 x 3840 @ 0.0
Closed
[2019-10-06 18:56:48.692] [error] [t=2352] D:\a\1\s\extern\Azure-Kinect-Sensor-SDK\src\image\image.c (51): k4a_image_t_get_context(). Invalid k4a_image_t 04AC6DE0
[2019-10-06 18:56:48.692] [error] [t=2352] D:\a\1\s\extern\Azure-Kinect-Sensor-SDK\src\image\image.c (333): Invalid argument to image_dec_ref(). image_handle (04AC6DE0) is not a valid handle of type k4a_image_t

But the device is opened and the snapshot is taken successfully.

In longer scripts (I am using Python wrapper py-k4a), this is causing the program to crash.

Expected Behavior

About 10% of the time, I instead get:

C:\Users\amy\caaliMICRO5\py-k4a>python example.py
Opened device 000666392412 (('rgb', (1, 6, 102)), ('depth', (1, 6, 75)), ('audio', (1, 6, 14)), ('depth_sensor', (6109, 7, 0)))

Capture: 2160 x 3840 @ 0.0
Closed

Also with a successful image capture.

In longer scripts (I am using Python wrapper py-k4a), this is causing the program to crash.

Desktop (please complete the following information):

  • OS with Version: Windows 10
  • SDK Version: 1.2.0
  • Firmware version: 1.6ish (Fresh install from Microsoft website on Sunday.)

from py-k4a.

amy-caali avatar amy-caali commented on July 19, 2024

Here was the Microsoft take on this issue:

"Sorry, I am not familiar with Python. My guess is that there is a marshalling issue between the C interface and the Python call.

Try asking the contributors working on the Python interface."

from py-k4a.

Related Issues (11)

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.