Skip to content

Instantly share code, notes, and snippets.

@culurciello
Created February 7, 2016 00:46
Show Gist options
  • Save culurciello/a990ff826f8f0fc15ece to your computer and use it in GitHub Desktop.
Save culurciello/a990ff826f8f0fc15ece to your computer and use it in GitHub Desktop.
local cv = require 'cv'
require 'cv.highgui'
require 'cv.imgproc'
require 'cv.imgcodecs'
require 'image'
-- local image = cv.imread{arg[1] or 'demo/lena.jpg', cv.IMREAD_GRAYSCALE}
imgT = image.lena()
imgT = image.lena()
imgTg = imgT[2] -- convert to grayscale and remove the first dimension
imgTgB = (imgTg*255):byte()
-- imgCV = imgT:transpose(1,2):transpose(2,3):clone()
-- cv.imshow{"Lena", imgCV};
local detector = cv.LineSegmentDetector{}
local lines = detector:detect{imgTgB}
imgCV = detector:drawSegments{imgTgB, lines}
cv.imshow{"Detected lines", imgCV}
cv.waitKey{0}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment