Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/ |
Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 2 | /* Copyright (c) FIRST 2014-2016. All Rights Reserved. */ |
Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ |
Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ |
| 5 | /* the project. */ |
Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 6 | /*----------------------------------------------------------------------------*/ |
| 7 | |
| 8 | #include "Vision/MonoImage.h" |
| 9 | #include "nivision.h" |
| 10 | |
| 11 | using namespace std; |
| 12 | |
| 13 | MonoImage::MonoImage() : ImageBase(IMAQ_IMAGE_U8) {} |
| 14 | |
| 15 | /** |
| 16 | * Look for ellipses in an image. |
| 17 | * Given some input parameters, look for any number of ellipses in an image. |
| 18 | * @param ellipseDescriptor Ellipse descriptor |
| 19 | * @param curveOptions Curve options |
| 20 | * @param shapeDetectionOptions Shape detection options |
| 21 | * @param roi Region of Interest |
| 22 | * @returns a vector of EllipseMatch structures (0 length vector on no match) |
| 23 | */ |
| 24 | vector<EllipseMatch> *MonoImage::DetectEllipses( |
| 25 | EllipseDescriptor *ellipseDescriptor, CurveOptions *curveOptions, |
| 26 | ShapeDetectionOptions *shapeDetectionOptions, ROI *roi) { |
| 27 | int numberOfMatches; |
| 28 | EllipseMatch *e = |
| 29 | imaqDetectEllipses(m_imaqImage, ellipseDescriptor, curveOptions, |
| 30 | shapeDetectionOptions, roi, &numberOfMatches); |
| 31 | auto ellipses = new vector<EllipseMatch>; |
| 32 | if (e == nullptr) { |
| 33 | return ellipses; |
| 34 | } |
| 35 | for (int i = 0; i < numberOfMatches; i++) { |
| 36 | ellipses->push_back(e[i]); |
| 37 | } |
| 38 | imaqDispose(e); |
| 39 | return ellipses; |
| 40 | } |
| 41 | |
| 42 | vector<EllipseMatch> *MonoImage::DetectEllipses( |
| 43 | EllipseDescriptor *ellipseDescriptor) { |
| 44 | vector<EllipseMatch> *ellipses = |
| 45 | DetectEllipses(ellipseDescriptor, nullptr, nullptr, nullptr); |
| 46 | return ellipses; |
| 47 | } |