- Find lower and upper ranges of HSV values
- Filter using color and find mask-color
- Optional: Filter using backgroundSubtractorMog2-> mask object movement AND both the masks
- Use erode, dilate and threshold to remove any noise
- Find contours. Assume that whatever contour we have are part of moving car, combine all points
- Find Centre of mass using moments
void readPixels(final Mat imageHSV) {
for (int i = 0; i < imageHSV.rows(); i++)
for (int j = 0; j < imageHSV.cols(); j++) {
double pixel[] = imageHSV.get(i, j);
for (int k = 0; k < pixel.length; k++)
System.out.print(pixel[k] + "\t");
System.out.println();
}
}
I have used GIMP to extract the car
This is converted to HSV and output from readPixels were copied to OpenOffice Calc (excel) to get the value ranges
final Scalar carColorThresholdHSVLow = new Scalar(90, 20, 180);
final Scalar carColorThresholdHSVHigh = new Scalar(102, 115, 255);
The output from Detection.
Source can be found here.
No comments:
Post a Comment