Skip to content

Instantly share code, notes, and snippets.

@matsadler
Last active February 25, 2016 23:20
Show Gist options
  • Save matsadler/bca0e39ca0b1365b0bc1 to your computer and use it in GitHub Desktop.
Save matsadler/bca0e39ca0b1365b0bc1 to your computer and use it in GitHub Desktop.
ruby-opencv Invalid sequence error bug
require "opencv"
image = OpenCV::CvMat.new(100, 100, OpenCV::CV_8U, 1).fill(0)
image[50,50] = OpenCV::CvColor::White
def foo(image)
image.find_contours
end
100_000.times do |i|
object = []
foo(image).first
end
# also encounters the same error, but takes longer
def foo(image)
image.find_contours
end
2_000_000.times {|i| foo(image).first}
# also encounters the same error
1_000_000.times do |i|
contours = image.find_contours
current = contours
current = current.h_next while current
contours.first
end
source "https://rubygems.org"
gem "ruby-opencv"
GEM
remote: https://rubygems.org/
specs:
ruby-opencv (0.0.14)
PLATFORMS
ruby
DEPENDENCIES
ruby-opencv
BUNDLED WITH
1.10.5
bug.rb:12:in `first': Invalid sequence error. (TypeError)
from bug.rb:12:in `block in <main>'
from bug.rb:10:in `times'
from bug.rb:10:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment