Giter Club home page Giter Club logo

blog's Introduction

findContours

基本用法

const im = cv.imread('image_path')
cv.cvtColor(im, im, cv.COLOR_RGB2GRAY)
cv.threshold(im, im, 127, 255, cv.THRESH_BINARY_INV)
const contours = new cv.MatVector()
const hierarchy = new cv.Mat()
cv.findContours(im, contours, hierarchy, cv.RETR_TREE, cv.CHAIN_APPROX_NONE)
Mode(轮廓的检索模式) 说明
cv.RETR_EXTERNAL 只检测最外层轮廓
cv.RETR_TREE 检测所有轮廓,获取轮廓层级关系
cv.RETR_LIST 检测所有轮廓,包括内围、外围轮廓,但是检测到的轮廓不建立等级关系
cv.RETR_CCOMP 检测所有轮廓,但所有轮廓只建立两个等级关系,外围为顶层
Method(轮廓的近似方法) 说明
cv.CHAIN_APPROX_NONE 保存物体边界上所有连续的轮廓点到contours向量内
cv.CHAIN_APPROX_SIMPLE 仅保存轮廓的拐点信息,把所有轮廓拐点处的点保存入contours向量内,拐点与拐点之间直线段上的信息点不予保留
cv.CHAIN_APPROX_TC89_L1
cv.CHAIN_APPROX_TC89_KCOS

blog's People

Contributors

gitbook-bot avatar jetlua avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.