I'm currently using https://www.npmjs.com/package/pixfinder to try and detect holes in my paper targets to automatically score my target. I placed it against a red backer board, took a picture of it and I was trying to find the "red" in the image.
Component code.
import * as pix from 'pixfinder';
@Component({
selector: 'app-find-bullets',
templateUrl: './find-bullets.component.html',
styleUrls: ['./find-bullets.component.scss']
})
export class FindBulletsComponent implements AfterViewInit {
bulletCount: number = 0;
@ViewChild('img') img!: ElementRef<HTMLImageElement>;
constructor() { }
ngAfterViewInit(): void {
var holes = pix.findAll({
img: this.img.nativeElement,
distance: 2,
colors: ['#6e0917'], //red
clearNoise: 10,
});
console.log(holes)
this.bulletCount = holes.length;
}
}
bulletCount is always "1", with the points being essentially the whole target if I'm reading this right: