Module: NL::KndClient::Kinutils

Defined in:
ext/kinutils/kinutils.c

Constant Summary collapse

DEPTH_LUT =
lut_array

Class Method Summary collapse

Class Method Details

.plot_front(data) ⇒ Object

gray depth image. Output: XPIXxYPIX 8-bit gray image.



212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'ext/kinutils/kinutils.c', line 212

VALUE rb_plot_front(VALUE self, VALUE data)
{
	VALUE outbuf;
	size_t len;

	// TODO: Allow reusing a previously-allocated output string

	Check_Type(data, T_STRING);
	len = RSTRING_LEN(data);
	if(len < 640 * 480 * 2) {
		rb_raise(rb_eArgError, "Input data must be at least 640*480*2 bytes (got %zu).", len);
	}

	// It seems rb_str_buf_new() adds a byte for terminating NUL, but
	// rb_str_resize() does not.
	outbuf = rb_str_buf_new(XPIX * YPIX - 1);
	rb_str_resize(outbuf, XPIX * YPIX);

	rb_thread_call_without_gvl(
			plot_front_blocking,
			&(struct plot_info){.in = (uint16_t *)RSTRING_PTR(data), .out = (uint8_t *)RSTRING_PTR(outbuf)},
			NULL,
			NULL
			);

	return outbuf;
}

.plot_linear(data) ⇒ Object

640x480x16bit gray depth image. Output: 640x480 8-bit gray image.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'ext/kinutils/kinutils.c', line 103

VALUE rb_plot_linear(VALUE self, VALUE data)
{
	VALUE outbuf;
	size_t len;

	// TODO: Allow reusing a previously-allocated output string

	Check_Type(data, T_STRING);
	len = RSTRING_LEN(data);
	if(len < 640 * 480 * 2) {
		rb_raise(rb_eArgError, "Input data must be at least 640*480*2 bytes (got %zu).", len);
	}

	// It seems rb_str_buf_new() adds a byte for terminating NUL, but
	// rb_str_resize() does not.
	outbuf = rb_str_buf_new(640 * 480 - 1);
	rb_str_resize(outbuf, 640 * 480);

	rb_thread_call_without_gvl(
			plot_linear_blocking,
			&(struct plot_info){.in = (uint16_t *)RSTRING_PTR(data), .out = (uint8_t *)RSTRING_PTR(outbuf)},
			NULL,
			NULL
			);
	return outbuf;
}

.plot_overhead(data) ⇒ Object

gray depth image. Output: XPIXxZPIX 8-bit gray image.



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'ext/kinutils/kinutils.c', line 139

VALUE rb_plot_overhead(VALUE self, VALUE data)
{
	VALUE outbuf;
	size_t len;

	// TODO: Allow reusing a previously-allocated output string

	Check_Type(data, T_STRING);
	len = RSTRING_LEN(data);
	if(len < 640 * 480 * 2) {
		rb_raise(rb_eArgError, "Input data must be at least 640*480*2 bytes (got %zu).", len);
	}

	// It seems rb_str_buf_new() adds a byte for terminating NUL, but
	// rb_str_resize() does not.
	outbuf = rb_str_buf_new(XPIX * ZPIX - 1);
	rb_str_resize(outbuf, XPIX * ZPIX);

	rb_thread_call_without_gvl(
			plot_overhead_blocking,
			&(struct plot_info){.in = (uint16_t *)RSTRING_PTR(data), .out = (uint8_t *)RSTRING_PTR(outbuf)},
			NULL,
			NULL
			);
	return outbuf;
}

.plot_side(data) ⇒ Object

gray depth image. Output: ZPIXxYPIX 8-bit gray image.



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'ext/kinutils/kinutils.c', line 175

VALUE rb_plot_side(VALUE self, VALUE data)
{
	VALUE outbuf;
	size_t len;

	// TODO: Allow reusing a previously-allocated output string

	Check_Type(data, T_STRING);
	len = RSTRING_LEN(data);
	if(len < 640 * 480 * 2) {
		rb_raise(rb_eArgError, "Input data must be at least 640*480*2 bytes (got %zu).", len);
	}

	// It seems rb_str_buf_new() adds a byte for terminating NUL, but
	// rb_str_resize() does not.
	outbuf = rb_str_buf_new(ZPIX * YPIX - 1);
	rb_str_resize(outbuf, ZPIX * YPIX);

	rb_thread_call_without_gvl(
			plot_side_blocking,
			&(struct plot_info){.in = (uint16_t *)RSTRING_PTR(data), .out = (uint8_t *)RSTRING_PTR(outbuf)},
			NULL,
			NULL
			);

	return outbuf;
}

.unpack11_to_16(data) ⇒ Object

Unpacks to 16-bit left-aligned values (for presentation, or passing into plot_linear)



83
84
85
86
# File 'ext/kinutils/kinutils.c', line 83

VALUE rb_unpack11_to_16(VALUE self, VALUE data)
{
	return internal_unpack11_to_16(0, data);
}

.unpack11_to_16_lut(data) ⇒ Object

Unpacks to 16-bit right-aligned values (for direct use in DEPTH_LUT)



89
90
91
92
# File 'ext/kinutils/kinutils.c', line 89

VALUE rb_unpack11_to_16_lut(VALUE self, VALUE data)
{
	return internal_unpack11_to_16(1, data);
}

.xworld(xpix, zw) ⇒ Object

into horizontal world-space millimeters from the sensor centerline.



390
391
392
393
# File 'ext/kinutils/kinutils.c', line 390

VALUE ext_xworld(VALUE self, VALUE xpix, VALUE zw)
{
	return INT2FIX(ku_xworld(NUM2INT(xpix), NUM2INT(zw)));
}

.yworld(ypix, zw) ⇒ Object

into vertical world-space millimeters from the sensor centerline.



397
398
399
400
# File 'ext/kinutils/kinutils.c', line 397

VALUE ext_yworld(VALUE self, VALUE ypix, VALUE zw)
{
	return INT2FIX(ku_yworld(NUM2INT(ypix), NUM2INT(zw)));
}