mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
add CvCapture
This commit is contained in:
parent
801de7fc1f
commit
7b7039ec86
3 changed files with 61 additions and 0 deletions
|
@ -4,3 +4,4 @@ require_relative "opencv/basic_structs"
|
|||
require_relative "opencv/cvmat"
|
||||
require_relative "opencv/iplimage"
|
||||
require_relative "opencv/cvhaarclassifiercascade"
|
||||
require_relative "opencv/cvcapture"
|
||||
|
|
10
lib/opencv/cvcapture.rb
Normal file
10
lib/opencv/cvcapture.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
module Cv
|
||||
class CvCapture < VideoCapture
|
||||
alias_method :query, :read
|
||||
alias_method :close, :release
|
||||
|
||||
def self.open(value = nil)
|
||||
self.new(value)
|
||||
end
|
||||
end
|
||||
end
|
50
test/legacy/test_cvcapture.rb
Executable file
50
test/legacy/test_cvcapture.rb
Executable file
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/env ruby
|
||||
# -*- mode: ruby; coding: utf-8 -*-
|
||||
require 'test/unit'
|
||||
require 'opencv'
|
||||
require File.expand_path(File.dirname(__FILE__)) + '/../helper'
|
||||
|
||||
include OpenCV
|
||||
|
||||
# Tests for OpenCV::CvCapture
|
||||
class TestCvCapture < OpenCVTestCase
|
||||
def setup
|
||||
@cap = CvCapture.open(AVI_SAMPLE)
|
||||
@cap.query
|
||||
end
|
||||
|
||||
def teardown
|
||||
@cap = nil
|
||||
end
|
||||
|
||||
def test_open
|
||||
cap1 = CvCapture.open(AVI_SAMPLE)
|
||||
assert_equal(CvCapture, cap1.class)
|
||||
|
||||
# Uncomment the following lines to test capturing from camera
|
||||
#
|
||||
# cap2 = CvCapture.open(0)
|
||||
# assert_equal(CvCapture, cap2.class)
|
||||
end
|
||||
|
||||
def test_close
|
||||
cap1 = CvCapture.open(AVI_SAMPLE)
|
||||
cap1.close
|
||||
assert_false(cap1.opened?)
|
||||
end
|
||||
|
||||
def test_grab
|
||||
assert(@cap.grab)
|
||||
end
|
||||
|
||||
def test_retrieve
|
||||
@cap.grab
|
||||
img = @cap.retrieve
|
||||
assert_equal(Mat, img.class)
|
||||
end
|
||||
|
||||
def test_query
|
||||
img = @cap.query
|
||||
assert_equal(Mat, img.class)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue