Class: Motion

Inherits:
Object
  • Object
show all
Defined in:
ext/rmotion/rmotion_main.c

Instance Method Summary collapse

Constructor Details

#initializeObject


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'ext/rmotion/rmotion_main.c', line 26

VALUE rb_motion_initialize (VALUE self)
{
	int i=0;
	VALUE entities = rb_ary_new();
	VALUE e;

	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);

	for (i=0;i<ENTITIES;i++) {
		e = rb_class_new_instance (0, 0, rb_cEntity);
		rb_ary_push(entities, e);
	}
	rb_iv_set(self,"entities",entities);
	
	/* DEFAULTS */
	mdp->mode = MODECAM;
	mdp->fft = 1;
	mdp->write = NULL;
	
	mdp->show = 1;
	mdp->fill = 1; 
	mdp->rect = 0;
	mdp->point = 0;

	mdp->threshold_distance = 9.0;
	mdp->threshold_group = 20;
	mdp->threshold_fft = 1;
	mdp->threshold_direct = 8;
	
	return self;
}

Instance Method Details

#camObject


307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'ext/rmotion/rmotion_main.c', line 307

VALUE rb_motion_cam (int argc, VALUE *argv, VALUE self)
{
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);
	VALUE camid;

	rb_scan_args(argc, argv, "01", &camid);
	if(NIL_P(camid)) {
		camid = INT2FIX(-1);
	}
	mdp->mode = MODECAM;
	mdp->camid = NUM2INT(camid);
	rmotion_process(self);
	return Qtrue;
}

#fft=Object


76
77
78
79
80
81
82
83
84
85
86
87
# File 'ext/rmotion/rmotion_cfg.c', line 76

VALUE rb_motion_fft_set (VALUE self, VALUE val)
{
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);
	if(RTEST(val)) {
		mdp->fft = 1;
		return Qtrue;
	} else {
		mdp->fft = 0;
		return Qfalse;
	}
}

#fft?Boolean

Returns:

  • (Boolean)

88
89
90
91
92
93
94
95
96
# File 'ext/rmotion/rmotion_cfg.c', line 88

VALUE rb_motion_fft_p (VALUE self) 
{
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);
	if (mdp->fft)
		return Qtrue;
	else
		return Qfalse;
}

#fill=Object


32
33
34
35
36
37
38
39
40
41
42
43
# File 'ext/rmotion/rmotion_cfg.c', line 32

VALUE rb_motion_fill_set (VALUE self, VALUE val)
{
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);
	if(RTEST(val)) {
		mdp->fill = 1;
		return Qtrue;
	} else {
		mdp->fill = 0;
		return Qfalse;
	}
}

#fill?Boolean

Returns:

  • (Boolean)

44
45
46
47
48
49
50
51
52
# File 'ext/rmotion/rmotion_cfg.c', line 44

VALUE rb_motion_fill_p (VALUE self) 
{
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);
	if (mdp->fill)
		return Qtrue;
	else
		return Qfalse;
}

#point=Object


98
99
100
101
102
103
104
105
106
107
108
109
# File 'ext/rmotion/rmotion_cfg.c', line 98

VALUE rb_motion_point_set (VALUE self, VALUE val)
{
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);
	if(RTEST(val)) {
		mdp->point = 1;
		return Qtrue;
	} else {
		mdp->point = 0;
		return Qfalse;
	}
}

#point?Boolean

Returns:

  • (Boolean)

110
111
112
113
114
115
116
117
118
# File 'ext/rmotion/rmotion_cfg.c', line 110

VALUE rb_motion_point_p (VALUE self) 
{
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);
	if (mdp->point)
		return Qtrue;
	else
		return Qfalse;
}

#quitObject


340
341
342
343
344
345
346
# File 'ext/rmotion/rmotion_main.c', line 340

VALUE rb_motion_quit (VALUE self) 
{
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);
	mdp->quit = 1;
	return Qtrue;
}

#rect=Object


54
55
56
57
58
59
60
61
62
63
64
65
# File 'ext/rmotion/rmotion_cfg.c', line 54

VALUE rb_motion_rect_set (VALUE self, VALUE val)
{
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);
	if(RTEST(val)) {
		mdp->rect = 1;
		return Qtrue;
	} else {
		mdp->rect = 0;
		return Qfalse;
	}
}

#rect?Boolean

Returns:

  • (Boolean)

66
67
68
69
70
71
72
73
74
# File 'ext/rmotion/rmotion_cfg.c', line 66

VALUE rb_motion_rect_p (VALUE self) 
{
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);
	if (mdp->rect)
		return Qtrue;
	else
		return Qfalse;
}

#show=Object


10
11
12
13
14
15
16
17
18
19
20
21
# File 'ext/rmotion/rmotion_cfg.c', line 10

VALUE rb_motion_show_set (VALUE self, VALUE val)
{
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);
	if(RTEST(val)) {
		mdp->show = 1;
		return Qtrue;
	} else {
		mdp->show = 0;
		return Qfalse;
	}
}

#show?Boolean

Returns:

  • (Boolean)

22
23
24
25
26
27
28
29
30
# File 'ext/rmotion/rmotion_cfg.c', line 22

VALUE rb_motion_show_p (VALUE self) 
{
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);
	if (mdp->show)
		return Qtrue;
	else
		return Qfalse;
}

#threshold_direct=Object


183
184
185
186
187
188
189
# File 'ext/rmotion/rmotion_cfg.c', line 183

VALUE rb_motion_th_direct_set (VALUE self, VALUE val)
{
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);
	mdp->threshold_direct = NUM2DBL(val);
	return val;
}

#threshold_direct?Boolean

Returns:

  • (Boolean)

191
192
193
194
195
196
# File 'ext/rmotion/rmotion_cfg.c', line 191

VALUE rb_motion_th_direct_p (VALUE self) 
{
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);
	return rb_float_new(mdp->threshold_direct);
}

#threshold_distance=Object


138
139
140
141
142
143
144
# File 'ext/rmotion/rmotion_cfg.c', line 138

VALUE rb_motion_th_distance_set (VALUE self, VALUE val)
{
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);
	mdp->threshold_distance = NUM2DBL(val);
	return val;
}

#threshold_distance?Boolean

Returns:

  • (Boolean)

146
147
148
149
150
151
# File 'ext/rmotion/rmotion_cfg.c', line 146

VALUE rb_motion_th_distance_p (VALUE self) 
{
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);
	return rb_float_new(mdp->threshold_distance);
}

#threshold_fft=Object


168
169
170
171
172
173
174
# File 'ext/rmotion/rmotion_cfg.c', line 168

VALUE rb_motion_th_fft_set (VALUE self, VALUE val)
{
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);
	mdp->threshold_fft = NUM2DBL(val);
	return val;
}

#threshold_fft?Boolean

Returns:

  • (Boolean)

176
177
178
179
180
181
# File 'ext/rmotion/rmotion_cfg.c', line 176

VALUE rb_motion_th_fft_p (VALUE self) 
{
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);
	return rb_float_new(mdp->threshold_fft);
}

#threshold_group=Object


153
154
155
156
157
158
159
# File 'ext/rmotion/rmotion_cfg.c', line 153

VALUE rb_motion_th_group_set (VALUE self, VALUE val)
{
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);
	mdp->threshold_group = NUM2INT(val);
	return val;
}

#threshold_group?Boolean

Returns:

  • (Boolean)

161
162
163
164
165
166
# File 'ext/rmotion/rmotion_cfg.c', line 161

VALUE rb_motion_th_group_p (VALUE self) 
{
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);
	return INT2FIX(mdp->threshold_group);
}

#vidObject


323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'ext/rmotion/rmotion_main.c', line 323

VALUE rb_motion_vid (int argc, VALUE *argv, VALUE self)
{
	VALUE vid;
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);

	rb_scan_args(argc, argv, "01", &vid);
	if(TYPE(vid) == T_STRING) {
		mdp->mode = MODEVID;
		mdp->vid = StringValuePtr(vid);
	} else {
		return Qfalse;
	}
	rmotion_process(self);
	return Qtrue;
}

#write=Object


120
121
122
123
124
125
126
# File 'ext/rmotion/rmotion_cfg.c', line 120

VALUE rb_motion_write_set (VALUE self, VALUE val)
{
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);
	Check_Type(val, T_STRING);
	mdp->write = StringValuePtr(val);
}

#write?Boolean

Returns:

  • (Boolean)

128
129
130
131
132
133
134
135
136
# File 'ext/rmotion/rmotion_cfg.c', line 128

VALUE rb_motion_write_p (VALUE self) 
{
	struct motion_data_t * mdp; 
	GetMD(motion_data,mdp);
	if (mdp->write != NULL)
		return Qtrue;
	else
		return Qfalse;
}