-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patht4kHSLImage.cpp
More file actions
executable file
·66 lines (56 loc) · 2.28 KB
/
t4kHSLImage.cpp
File metadata and controls
executable file
·66 lines (56 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#include "t4kHSLImage.h"
/**
* Create a new image that uses the Hue, Saturation, and Luminance planes.
*/
t4kHSLImage::t4kHSLImage() : ColorImage(IMAQ_IMAGE_HSL)
{
}
/**
* Create a new image by loading a file.
* @param fileName The path of the file to load.
*/
t4kHSLImage::t4kHSLImage(const char *fileName) : ColorImage(IMAQ_IMAGE_HSL)
{
int success = imaqReadFile(m_imaqImage, fileName, NULL, NULL);
wpi_setImaqErrorWithContext(success, "Imaq ReadFile error");
}
t4kHSLImage::~t4kHSLImage()
{
}
/**
* Perform a threshold operation on a ColorImage.
* Perform a threshold operation on a ColorImage using the ColorMode supplied
* as a parameter.
* @param colorMode The type of colorspace this operation should be performed in
* @returns a pointer to a binary image
*/
int t4kHSLImage::ComputeThreshold(ColorMode colorMode,
int low1, int high1,
int low2, int high2,
int low3, int high3,
t4kBinaryImage& iResult)
{
Range range1 = {low1, high1},
range2 = {low2, high2},
range3 = {low3, high3};
int success = imaqColorThreshold(iResult.GetImaqImage(), m_imaqImage, 1, colorMode, &range1, &range2, &range3);
wpi_setImaqErrorWithContext(success, "ImaqThreshold error");
return success;
}
/**
* Perform a threshold in HSV space.
* @param threshold a reference to the Threshold object to use.
* @returns A pointer to a BinaryImage that represents the result of the threshold operation.
*/
int t4kHSLImage::ThresholdHSV(Threshold &t, t4kBinaryImage& iResult)
{
return ComputeThreshold(IMAQ_HSV, t.plane1Low, t.plane1High,
t.plane2Low, t.plane2High,
t.plane3Low, t.plane3High,
iResult);
}