c# - BlobCounter unsupported pixel format -
i getting current exception:
unsupportedimageformatexception: unsupported pixel format of source image. aforge.imaging.blobcounter.buildobjectsmap (aforge.imaging.unmanagedimage image) aforge.imaging.blobcounterbase.processimage (aforge.imaging.unmanagedimage image) aforge.imaging.blobcounterbase.processimage (system.drawing.imaging.bitmapdata imagedata) aforge.imaging.blobcounterbase.processimage (system.drawing.bitmap image) cam.blobcounter (system.drawing.bitmap videooutput, aforge.imaging.blobcounter bc) (at assets/scripts/cam.cs:127) cam.update () (at assets/scripts/cam.cs:69)
which caused blobcounter not accepting current image format. fix used convertion method: bitmap yellowclone = aforge.imaging.image.clone(originalbm, system.drawing.imaging.pixelformat.format32bppargb);
but still error(despite trying every format available).
for context, here code, originalfeedtexture being webcam feed:
byte[] bytes = originalfeedtexture.encodetojpg(); using (var ms = new memorystream(bytes)) { originalbm = new bitmap(ms); } bitmap yellowclone = aforge.imaging.image.clone(originalbm, system.drawing.imaging.pixelformat.format32bppargb); yellow = new bitmap(yellowclone); yellowfilter(yellow); blobcounter bc = new blobcounter(); blobcounter(yellowclone, bc); rectangle[] rects = bc.getobjectsrectangles(); if (bc.objectscount >= 1) { debug.log("swedes"); }
my yellowfilter function:
void yellowfilter(bitmap videooutput) { hslfiltering yellowhslfilter = new hslfiltering(); yellowhslfilter.hue = new intrange(40, 70); yellowhslfilter.saturation = new doublerange(0.3f, 0.9f); yellowhslfilter.luminance = new doublerange(0.3f, 0.8f); yellowhslfilter.applyinplace(videooutput); }
and blobcounter function:
void blobcounter(bitmap videooutput, blobcounter bc) { bc.objectsorder = objectsorder.size; bc.processimage(videooutput); }
edit: forgot mention, error on following line: blobcounter(yellowclone, bc);
i fixed issue changing version number of aforge.net. tested on multiple versions, , seems when using exact code, issue appears on 2.0.0 version.
Comments
Post a Comment