Module: MatrixCreator::Vision
- Defined in:
- lib/matrix_creator/vision.rb
Overview
Module: Vision
Communicate with the vision driver
Constant Summary collapse
- VISION_CONFIG =
Configuration values for the Vision driver
MatrixCreator.settings[:devices][:vision]
- BASE_PORT =
Base port to send data to Vision driver
VISION_CONFIG[:port]
- CAMERA_WIDTH =
Camera width value
1280- CAMERA_HEIGHT =
Camera height value
720
Class Method Summary collapse
-
.detect_demographics ⇒ Object
Detect demographics of a face.
-
.detect_face ⇒ Object
Detect one face message.
-
.detect_fist ⇒ Object
Detect a fist.
-
.detect_objects(objects, options = {}, &block) ⇒ Array
Detect a list of objects that are on detected by the camera, specifying the amount of max responses or max seconds to detect elements on camera.
-
.detect_once(object) ⇒ Object
Detects an object once.
-
.detect_palm ⇒ Object
Detect a palm.
-
.detect_pinch ⇒ Object
Detect a pinch.
-
.detect_thumb_up ⇒ Object
Detect a thumbs up.
Class Method Details
.detect_demographics ⇒ Object
Detect demographics of a face
130 131 132 |
# File 'lib/matrix_creator/vision.rb', line 130 def self.detect_demographics detect_once(MatrixMalos::EnumMalosEyeDetectionType::FACE_DEMOGRAPHICS) end |
.detect_face ⇒ Object
Detect one face message
120 121 122 |
# File 'lib/matrix_creator/vision.rb', line 120 def self.detect_face detect_once(MatrixMalos::EnumMalosEyeDetectionType::FACE) end |
.detect_fist ⇒ Object
Detect a fist
170 171 172 |
# File 'lib/matrix_creator/vision.rb', line 170 def self.detect_fist detect_once(MatrixMalos::EnumMalosEyeDetectionType::HAND_FIST) end |
.detect_objects(objects, options = {}, &block) ⇒ Array
Detect a list of objects that are on detected by the camera, specifying the amount of max responses or max seconds to detect elements on camera
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/matrix_creator/vision.rb', line 50 def self.detect_objects(objects, = {}, &block) @vision_comm = MatrixCreator::Comm.new(BASE_PORT) # Setup MalosEye configuration malos_eye_config = MatrixMalos::MalosEyeConfig.new( camera_config: MatrixMalos::CameraConfig.new( camera_id: 0, width: CAMERA_WIDTH, height: CAMERA_HEIGHT ) ) # Generate driver configuration config = MatrixMalos::DriverConfig.new( malos_eye_config: malos_eye_config, delay_between_updates: 0.1, timeout_after_last_ping: 4 ) @vision_comm.send_configuration(config) # Setup objects to detect malos_eye_config = MatrixMalos::MalosEyeConfig.new objects.each do |object| malos_eye_config.object_to_detect.push(object) end config = MatrixMalos::DriverConfig.new( malos_eye_config: malos_eye_config ) @vision_comm.send_configuration(config) # Query Demographics result = @vision_comm.perform(AdmobilizeVision::VisionResult, , block) # Stop capturing events malos_eye_config = MatrixMalos::MalosEyeConfig.new malos_eye_config.object_to_detect.push(MatrixMalos::EnumMalosEyeDetectionType::STOP) config = MatrixMalos::DriverConfig.new(malos_eye_config: malos_eye_config) @vision_comm.send_configuration(config) # Destroy context @vision_comm.destroy result end |
.detect_once(object) ⇒ Object
Detects an object once
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/matrix_creator/vision.rb', line 102 def self.detect_once(object) result = nil # Loop until recDetection is returned loop do result = detect_objects([object], max_resp: 1).first break unless result[:rectDetection].empty? end result end |
.detect_palm ⇒ Object
Detect a palm
150 151 152 |
# File 'lib/matrix_creator/vision.rb', line 150 def self.detect_palm detect_once(MatrixMalos::EnumMalosEyeDetectionType::HAND_PALM) end |
.detect_pinch ⇒ Object
Detect a pinch
160 161 162 |
# File 'lib/matrix_creator/vision.rb', line 160 def self.detect_pinch detect_once(MatrixMalos::EnumMalosEyeDetectionType::HAND_PINCH) end |
.detect_thumb_up ⇒ Object
Detect a thumbs up
140 141 142 |
# File 'lib/matrix_creator/vision.rb', line 140 def self.detect_thumb_up detect_once(MatrixMalos::EnumMalosEyeDetectionType::HAND_THUMB_UP) end |