Addressing comments on pull request.
Minor changes to the documentation comments to ensure everything works as expected. Minor refactoring removed to place in a separate branch.
This commit is contained in:
Родитель
7e82cd6cc2
Коммит
2320a1dcca
|
@ -153,12 +153,7 @@ namespace LineDetector
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes a frame upon arrival.
|
||||
/// </summary>
|
||||
/// <param name="frameNo">The index of the frame to process.</param>
|
||||
/// <param name="boxes">A list of bounding boxes of items in frame.</param>
|
||||
/// <param name="mask">A mask detailing the precise layout of items in the frame using black to indicate vacant space, and white to indicate occupied space.</param>
|
||||
/// <inheritdoc/>
|
||||
public void notifyFrameArrival(int frameNo, List<Box> boxes, Bitmap mask)
|
||||
{
|
||||
for (int i = 0; i < noLines; i++)
|
||||
|
@ -172,11 +167,7 @@ namespace LineDetector
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes a frame upon arrival.
|
||||
/// </summary>
|
||||
/// <param name="frameNo">The index of the frame to process.</param>
|
||||
/// <param name="mask">A mask detailing the precise layout of items in the frame using black to indicate vacant space, and white to indicate occupied space.</param>
|
||||
/// <inheritdoc/>
|
||||
public void notifyFrameArrival(int frameNo, Bitmap mask)
|
||||
{
|
||||
for (int i = 0; i < noLines; i++)
|
||||
|
@ -192,7 +183,6 @@ namespace LineDetector
|
|||
/// <summary>
|
||||
/// Gets the number of times that this detector has been triggered.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int getCount()
|
||||
{
|
||||
return Count;
|
||||
|
@ -201,7 +191,6 @@ namespace LineDetector
|
|||
/// <summary>
|
||||
/// Gets the bounding box of the line used by this detector.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Box getBbox()
|
||||
{
|
||||
return Bbox;
|
||||
|
@ -210,7 +199,6 @@ namespace LineDetector
|
|||
/// <summary>
|
||||
/// Sets the count of this detector.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void setCount(int value)
|
||||
{
|
||||
Count = value;
|
||||
|
@ -223,7 +211,7 @@ namespace LineDetector
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <c>Dictionary</c> of the parameters used by this detector, stored by name.
|
||||
/// Gets a <see cref="Dictionary{TKey, TValue}"/> of the parameters used by this detector, stored by name.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Dictionary<string, Object> getParameters()
|
||||
|
@ -238,7 +226,7 @@ namespace LineDetector
|
|||
/// <summary>
|
||||
/// Gets the current occupancy state of this detector. This updates when the detector is notified of a frame arrival.
|
||||
/// </summary>
|
||||
/// <returns>Returns true if the line is occupied, and false otherwise.</returns>
|
||||
/// <returns><see langword="true"/> if the line is occupied; otherwise, <see langword="false"/>.</returns>
|
||||
public bool getOccupancy()
|
||||
{
|
||||
return lineCrossingDetectors[0].getOccupancy();
|
||||
|
@ -247,7 +235,6 @@ namespace LineDetector
|
|||
/// <summary>
|
||||
/// Gets the line segments used by this detector.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<(Point p1, Point p2)> getLineCoor()
|
||||
{
|
||||
List<(Point p1, Point p2)> coors = new List<(Point p1, Point p2)>();
|
||||
|
|
|
@ -18,30 +18,24 @@ namespace LineDetector
|
|||
/// <summary>
|
||||
/// The first point of the line.
|
||||
/// </summary>
|
||||
public Point p1 { get; set; }
|
||||
public Point p1;
|
||||
|
||||
/// <summary>
|
||||
/// The second point of the line.
|
||||
/// </summary>
|
||||
public Point p2 { get; set; }
|
||||
public Point p2;
|
||||
|
||||
/// <summary>
|
||||
/// The step size used to determine occupancy.
|
||||
/// </summary>
|
||||
public double increment { get; set; }
|
||||
public double increment;
|
||||
|
||||
/// <summary>
|
||||
/// The overlap threshold used to determine occupancy.
|
||||
/// </summary>
|
||||
public double overlapFractionThreshold { get; set; } = DEFAULT_OCCUPANCY_THRESHOLD;
|
||||
public double overlapFractionThreshold = DEFAULT_OCCUPANCY_THRESHOLD;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="DetectionLine"/> using the given coordinates.
|
||||
/// </summary>
|
||||
/// <param name="a">The X coordinate of the first point of the line.</param>
|
||||
/// <param name="b">The Y coordinate of the first point of the line.</param>
|
||||
/// <param name="c">The X coordinate of the second point of the line.</param>
|
||||
/// <param name="d">The Y coordinate of the second point of the line.</param>
|
||||
/// <inheritdoc cref="DetectionLine(int, int, int, int, double)"/>
|
||||
public DetectionLine(int a, int b, int c, int d)
|
||||
{
|
||||
p1 = new Point(a, b);
|
||||
|
@ -73,8 +67,9 @@ namespace LineDetector
|
|||
/// <param name="b">The bounding box of the area of interest in the mask.</param>
|
||||
/// <param name="mask">A mask detailing the precise layout of items in the frame using black to indicate vacant space, and white to indicate occupied space.</param>
|
||||
/// <returns>
|
||||
/// Returns a value from 0 to 1 indicating the fraction of the line which
|
||||
/// overlaps the given mask with 0 indicating no overlap and 1 indicating complete overlap.
|
||||
/// Returns the fraction of this DetectionLine that overlaps
|
||||
/// the given mask, from 0 indicating no overlap to 1 indicating
|
||||
/// complete overlap.
|
||||
/// </returns>
|
||||
public double getFractionContainedInBox(Box b, Bitmap mask)
|
||||
{
|
||||
|
@ -94,7 +89,7 @@ namespace LineDetector
|
|||
|
||||
bool isInside = b.IsPointInterior((int)currentX, (int)currentY);
|
||||
|
||||
if (mask.GetPixel((int)currentX, (int)currentY).ToArgb() == (~0) )
|
||||
if (mask.GetPixel((int)currentX, (int)currentY).ToString() == "Color [A=255, R=255, G=255, B=255]" )
|
||||
{
|
||||
overlapCount++;
|
||||
}
|
||||
|
@ -114,9 +109,9 @@ namespace LineDetector
|
|||
/// </summary>
|
||||
/// <param name="mask">A mask detailing the precise layout of items in the frame using black to indicate vacant space, and white to indicate occupied space.</param>
|
||||
/// <returns>
|
||||
/// Returns the fraction, from 0 to 1, of this <see cref="DetectionLine"/> that
|
||||
/// overlaps the given mask with a value of 0 indicating no overlap and a value of 1
|
||||
/// indicating complete overlap.
|
||||
/// Returns the fraction of this DetectionLine that overlaps
|
||||
/// the given mask, from 0 indicating no overlap to 1 indicating
|
||||
/// complete overlap.
|
||||
/// </returns>
|
||||
public double getFractionInForeground(Bitmap mask)
|
||||
{
|
||||
|
@ -134,7 +129,7 @@ namespace LineDetector
|
|||
|
||||
totalPixelCount++;
|
||||
|
||||
if ( mask.GetPixel( (int)currentX, (int)currentY ).ToArgb() == ( ~0 ) )
|
||||
if ( mask.GetPixel( (int)currentX, (int)currentY ).ToString() == "Color [A=255, R=255, G=255, B=255]" )
|
||||
{
|
||||
overlapCount++;
|
||||
}
|
||||
|
@ -155,7 +150,7 @@ namespace LineDetector
|
|||
/// </summary>
|
||||
/// <param name="boxes">The list of <see cref="Box"/> objects to check, representing the bounding boxes of items in frame.</param>
|
||||
/// <param name="mask">A mask detailing the precise layout of items in the frame using black to indicate vacant space, and white to indicate occupied space.</param>
|
||||
/// <returns>Returns a <see cref="Tuple{double, Box}"/> containing both the maximum overlap fraction found, and the <see cref="Box"/> associated with that overlap.</returns>
|
||||
/// <returns>Returns a tuple containing both the maximum overlap fraction found, and the <see cref="Box"/> associated with that overlap.</returns>
|
||||
public (double frac, Box b) getMaximumFractionContainedInAnyBox(List<Box> boxes, Bitmap mask)
|
||||
{
|
||||
double maxOverlapFraction = 0;
|
||||
|
@ -180,7 +175,7 @@ namespace LineDetector
|
|||
/// <param name="boxes">The bounding boxes of items in the frame.</param>
|
||||
/// <param name="mask">A mask detailing the precise layout of items in the frame using black to indicate vacant space, and white to indicate occupied space.</param>
|
||||
/// <returns>
|
||||
/// Returns a <see cref="Tuple{bool, Box}"/> containing a boolean indicating whether this line is
|
||||
/// Returns a tuple containing a boolean indicating whether this line is
|
||||
/// occupied, and the bounding box of the occupying item if so. If this line is
|
||||
/// unoccupied, the bounding box will be null.
|
||||
/// </returns>
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace LineDetector
|
|||
/// <param name="fgmask">The foreground mask of the frame.</param>
|
||||
/// <param name="boxes">A list of bounding boxes of items in the frame which deviate from the background.</param>
|
||||
/// <returns>
|
||||
/// <para>Returns a <see cref="Tuple"/> with two <see cref="Dictionary{TKey, TValue}">Dictionaries</see>.</para>
|
||||
/// <para>Returns a tuple with two <see cref="Dictionary{TKey, TValue}">Dictionaries</see>.</para>
|
||||
/// <para>The first dictionary contains the number of items which cross the lines of interest, indexed by line name.</para>
|
||||
/// <para>The second dictionary contains a boolean for each line indicating whether or not an item is present at that line.</para>
|
||||
/// </returns>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
/// <returns>Returns true if an event was detected, and false otherwise.</returns>
|
||||
bool notifyOccupancy(int frameNo, bool occupancy);
|
||||
|
||||
//TODO(isaach): Should be a property.
|
||||
//TODO(iharwell): Should be a property.
|
||||
/// <summary>
|
||||
/// Gets the occupancy state of the detector as of the latest frame.
|
||||
/// </summary>
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace LineDetector
|
|||
/// <param name="mask">A mask detailing the precise layout of items in the frame using black to indicate vacant space, and white to indicate occupied space.</param>
|
||||
void notifyFrameArrival(int frameNo, Bitmap mask);
|
||||
|
||||
//TODO(isaach): This should be moved somewhere more appropriate.
|
||||
//TODO(iharwell): This should be moved somewhere more appropriate.
|
||||
/// <summary>
|
||||
/// Activates debug logging.
|
||||
/// </summary>
|
||||
|
@ -57,7 +57,7 @@ namespace LineDetector
|
|||
/// <returns></returns>
|
||||
int getCount();
|
||||
|
||||
//TODO(isaach): This seems like it should not be part of the interface.
|
||||
//TODO(iharwell): This seems like it should not be part of the interface.
|
||||
/// <summary>
|
||||
/// Sets the count of this detector.
|
||||
/// </summary>
|
||||
|
|
|
@ -5,7 +5,7 @@ using BGSObjectDetector;
|
|||
|
||||
namespace LineDetector
|
||||
{
|
||||
//TODO(isaach): Pull methods into a separate interface for things that overlap with ICrossingDetector and ILineBasedDetector.
|
||||
//TODO(iharwell): Pull methods into a separate interface for things that overlap with ICrossingDetector and ILineBasedDetector.
|
||||
/// <summary>
|
||||
/// Interface for a line crossing detector that uses a single line for detection.
|
||||
/// </summary>
|
||||
|
|
Загрузка…
Ссылка в новой задаче