آموزش پردازش تصویر با opencv - بخش ششم

Download آموزش پردازش تصویر با OpenCV - بخش ششم

If you can't read please download the document

Post on 08-Jan-2017

212 views

Category:

Education

95 download

Embed Size (px)

TRANSCRIPT

  • faradars.org/fvimg9405

    :

    :

    FaraDars.org

  • faradars.org/fvimg9405

    ......

    2

    FaraDars.org

  • faradars.org/fvimg9405

    3

    FaraDars.org

  • faradars.org/fvimg9405

    .

    ..:

    .

    ..

    4

    FaraDars.org

  • faradars.org/fvimg9405

    cv::CannyOpenCV

    ..:

    5

    C++: void Canny(InputArray image, OutputArray edges, double threshold1,

    double threshold2, int apertureSize=3, boolL2gradient=false )

    FaraDars.org

  • faradars.org/fvimg9405

    .

    ...

    ..2

    .

    6

    FaraDars.org

  • faradars.org/fvimg9405

    .

    7

    FaraDars.org

  • faradars.org/fvimg9405

    8

    FaraDars.org

  • faradars.org/fvimg9405

    .

    9

    ...

    FaraDars.org

  • faradars.org/fvimg9405

    :

    = +

    ()p0.

    .p.

    10

    FaraDars.org

  • faradars.org/fvimg9405

    ..

    .

    ,p). ).

    .

    11

    FaraDars.org

  • faradars.org/fvimg9405

    OpenCV..cv::HoughLines

    ()..

    2cv::Vec2f,p) ).

    rho, theta..cv::HoughLines

    12

    C++: void HoughLines(InputArray image, OutputArray lines, double rho, double theta, int threshold)

    FaraDars.org

  • faradars.org/fvimg9405

    ..

    ()OpenCV.

    cv::HoughLinesP.

    cv::Vec4i.

    13

    C++: void HoughLinesP(InputArray image, OutputArray lines, double rho, double theta,

    int threshold, double minLineLength=0, double maxLineGap=0 )

    FaraDars.org

  • faradars.org/fvimg9405

    ..

    )..(

    2.

    .

    14

    FaraDars.org

  • faradars.org/fvimg9405

    .

    2 = 02 + 0

    2

    .()3.cv::HoughCircles

    15

    C++: void HoughCircles(InputArray image, OutputArray circles, int method, double dp,

    double minDist, double param1=100, double param2=100, int minRadius=0, int maxRadius=0 )

    FaraDars.org

  • faradars.org/fvimg9405

    16

    C++: void HoughCircles(InputArray image, OutputArray circles, int method, double dp,

    double minDist, double param1=100, double param2=100, int minRadius=0, int maxRadius=0 )

    src_gray: Input image (grayscale)

    circles: A vector that stores sets of 3 values: for each detected circle.

    CV_HOUGH_GRADIENT: Define the detection method. Currently this is the only one available in OpenCV

    dp = 1: The inverse ratio of resolution

    min_dist = src_gray.rows/8: Minimum distance between detected centers

    param_1 = 200: Upper threshold for the internal Canny edge detector

    param_2 = 100*: Threshold for center detection.

    min_radius = 0: Minimum radio to be detected. If unknown, put zero as default.

    max_radius = 0: Maximum radius to be detected. If unknown, put zero as default

    FaraDars.org

  • faradars.org/fvimg9405

    .

    17

    FaraDars.org

  • faradars.org/fvimg9405

    18

    FaraDars.org

  • faradars.org/fvimg9405

    )cv::Vec4f2.(.

    std::vectorcv::Mat.)

    .(

    19

    C++: void fitLine(InputArray points, OutputArray line, int distType, double param, double reps, double aeps)

    FaraDars.org

  • faradars.org/fvimg9405

    CV_DIST_L2.

    .

    .M-estimator)

    .(.

    cv::Point3icv::Point3fcv::Vec6f.

    20

    C++: void fitLine(InputArray points, OutputArray line, int distType, double param, double reps, double aeps)

    FaraDars.org

  • faradars.org/fvimg9405

    cv::fitEllipse

    (cv::RotatedRect)..

    :

    .cv::ellipse

    21

    C++: RotatedRect fitEllipse(InputArray points)

    FaraDars.org

  • faradars.org/fvimg9405

    22

    FaraDars.org

  • faradars.org/fvimg9405

    .

    ..-canny

    ..

    OpenCVcvFindContours().

    23

    FaraDars.org

  • faradars.org/fvimg9405

    24

    FaraDars.org

  • faradars.org/fvimg9405

    OpenCVcv::findContours

    .

    ()cvCanny ()cvThreshold

    ..cv::PointHierarchy.

    ..

    25

    C++: void findContours(InputOutputArray image, OutputArrayOfArrays contours,

    OutputArray hierarchy, int mode, int method, Point offset=Point())

    FaraDars.org

  • faradars.org/fvimg9405

    26

    C++: void findContours(InputOutputArray image, OutputArrayOfArrays contours,

    OutputArray hierarchy, int mode, int method, Point offset=Point())

    ,CV_RETR_EXTERNAL: modeCV_RETR_LIST, CV_RETR_CCOMP, CV_RETR_TREE.

    mode ,h_prev, h_next).

    v_prev, and v_next) mode.

    FaraDars.org

  • faradars.org/fvimg9405

    27

    C++: void findContours(InputOutputArray image, OutputArrayOfArrays contours,

    OutputArray hierarchy, int mode, int method, Point offset=Point())

    CV_RETR_EXTERNAL.CV_RETR_LIST.CV_RETR_CCOMP

    ..

    CV_RETR_TREE.2.

    .2.

    FaraDars.org

  • faradars.org/fvimg9405

    28

    FaraDars.org

  • faradars.org/fvimg9405

    ..

    .

    .

    29

    FaraDars.org

  • faradars.org/fvimg9405

    30

    C++: void findContours(InputOutputArray image, OutputArrayOfArrays contours,

    OutputArray hierarchy, int mode, int method, Point offset=Point())

    (.) methodCV_CHAIN_CODE.

    (.)CV_CHAIN_APPROX_NONE.CV_CHAIN_APPROX_SIMPLE

    .CV_CHAIN_APPROX_TC89_L1CV_CHAIN_APPROX_TC89_KCOS

    .Teh-ChinCV_LINK_RUNS1()

    .CV_RETR_LIST

    FaraDars.org

  • faradars.org/fvimg9405

    31

    FaraDars.org

  • faradars.org/fvimg9405

    32

    C++: void findContours(InputOutputArray image, OutputArrayOfArrays contours,

    OutputArray hierarchy, int mode, int method, Point offset=Point())

    .hierrachycontoursContours.Hierarchy.4i

    hierarchy[i][0]hierarchy[i][1]hierarchy[i][2]hierarchy[i][3]

    FaraDars.org

  • faradars.org/fvimg9405

    .OpenCV

    ..

    .thickness=CV_FILLEDthickness.maxLevelhierarchy

    33

    void drawContours(InputOutputArray image, InputArrayOfArrays contours, int contourIdx,const Scalar& color, int thickness=1, int lineType=8, InputArray hierarchy=noArray(),

    int maxLevel=INT_MAX, Point offset=Point() )

    FaraDars.org

  • faradars.org/fvimg9405

    .

    34

    .

    .

    FaraDars.org

  • faradars.org/fvimg9405

    35

    FaraDars.org

  • faradars.org/fvimg9405

    ...

    .

    36

    FaraDars.org

  • faradars.org/fvimg9405

    :

    Bounding) box)

    37

    FaraDars.org

  • faradars.org/fvimg9405

    :

    Polygonal approximation

    38

    FaraDars.org

  • faradars.org/fvimg9405

    :

    39

    C++: Moments moments(InputArray array, bool binaryImage=false (

    FaraDars.org

  • faradars.org/fvimg9405

    40

    .

    FaraDars.org

  • faradars.org/fvimg9405

    41

    .

    .

    faradars.org/fvimg9405

    faradars.org/fvimg9405

    FaraDars.org