Skip to content

Add serial option for connecting to Kinect2 #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions binding/freenect2-c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ static ColorCameraParams freenect2_device_get_color_camera_params(
return device->getColorCameraParams();
}

static void freenect2_device_set_color_auto_exposure(
Freenect2DeviceRef device_ref, float exposure_compensation)
{
Freenect2Device* device = reinterpret_cast<Freenect2Device*>(device_ref);
device->setColorAutoExposure(exposure_compensation);
}

typedef int (*Freenect2FrameListenerFunc) (
Freenect2FrameType type, Freenect2FrameRef frame, void *user_data);

Expand Down
3 changes: 3 additions & 0 deletions binding/freenect2_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
ColorCameraParams freenect2_device_get_color_camera_params(
Freenect2DeviceRef device_ref);

void freenect2_device_set_color_auto_exposure(
Freenect2DeviceRef device_ref, float exposure_compensation);

typedef int (*Freenect2FrameListenerFunc) (
Freenect2FrameType type, Freenect2FrameRef frame, void *user_data);
Freenect2FrameListenerRef freenect2_frame_listener_create(
Expand Down
11 changes: 10 additions & 1 deletion freenect2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ class Device(object):

"""

def __init__(self, c_object=None):
def __init__(self, c_object=None, serial=None):
if serial is not None:
c_object = lib.freenect2_open_device_by_serial(_get_freenect2(), serial)
if c_object is None:
c_object = lib.freenect2_open_default_device(_get_freenect2())
self._c_object = c_object
Expand Down Expand Up @@ -321,6 +323,13 @@ def running(self, *args, **kwargs):
yield self
self.stop()

def set_color_auto_exposure(self, exposure_compensate):
""" Function for exposure setting, range between [-2.0,2.0]

"""

lib.freenect2_device_set_color_auto_exposure(self._c_object, exposure_compensate)

def __iter__(self):
def iterator():
while True:
Expand Down