rmotion 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,64 @@
1
+ require 'rmotion.so'
2
+
3
+ class Entity
4
+
5
+ def initialize
6
+ @tlx = @tly = @brx = @bry = nil
7
+ @@radius = 60
8
+ end
9
+
10
+ def center
11
+ [(@tlx+@brx)/2,(@tly+@bry)/2] unless @tlx.nil?
12
+ end
13
+
14
+ def corners
15
+ [@tlx,@tly,@brx,@bry]
16
+ end
17
+
18
+ def compare oth
19
+ if center.nil? or oth.center.nil?
20
+ false
21
+ else
22
+ ((center.first - oth.center.first).abs < @@radius) and ((center.last - oth.center.last).abs < @@radius)
23
+ end
24
+ end
25
+
26
+ def self.reorder previous, current
27
+
28
+ previous.each_with_index do |p,i|
29
+ next if p.center.nil?
30
+ found = false
31
+ current.each_with_index do |c,k|
32
+ if p.compare c
33
+ previous[i] = c
34
+ current[k] = Entity.new
35
+ found = true
36
+ break
37
+ end
38
+ end
39
+ unless found
40
+ previous[i] = Entity.new
41
+ end
42
+ end
43
+
44
+ current.each do |c|
45
+ next if c.center.nil?
46
+ previous.each_with_index do |p,i|
47
+ if p.center.nil?
48
+ previous[i] = c
49
+ break
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ def self.status
56
+ status = []
57
+ 8.times do
58
+ status << Entity.new
59
+ end
60
+ status
61
+ end
62
+
63
+ end
64
+
Binary file
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rmotion
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Riccardo Cecolin
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-07-08 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: RMotion provides a simple interface to build motion detection software in ruby. Many kind of informations about moving entities will be available to applications, and the algorithm is heavily customizable since different cameras record different levels of noise.
22
+ email: rikiji@playkanji.com
23
+ executables: []
24
+
25
+ extensions:
26
+ - ext/rmotion/extconf.rb
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - examples/video.rb
31
+ - examples/cam.rb
32
+ - ext/rmotion/extconf.rb
33
+ - ext/rmotion/rmotion.h
34
+ - ext/rmotion/rmotion_main.c
35
+ - ext/rmotion/rmotion_cfg.c
36
+ - lib/rmotion.so
37
+ - lib/rmotion.rb
38
+ - LICENSE
39
+ - README
40
+ has_rdoc: true
41
+ homepage: http://www.rikiji.it
42
+ licenses:
43
+ - GPL
44
+ post_install_message:
45
+ rdoc_options: []
46
+
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 0
55
+ version: "0"
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ requirements: []
64
+
65
+ rubyforge_project:
66
+ rubygems_version: 1.3.6
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: RMotion provides a simple interface to build motion detection software in ruby.
70
+ test_files: []
71
+