Closed wmaiouiru closed 11 years ago
what is the data format of static image? is it 4 channel or 3? i have to try with static image to see if its format differs from webcam
as far as i know getImageData should always return RGBA format. so probably the problem that u didnt draw image to canvas before trying to getImageData
Thank you for the reply. The problem was not the RGBA format, but rather, it was the image not drawn to the canvas before trying to getImageData. jsfeat.imgproc.grayscale worked fine after making a button to process the image.
Hello, I am trying to convert an jpg image from color to gray-scale using jsfeat, but all of the color is coming out to black. The following is the code I use.
var image_data=ctx.getImageData(0,0,default_width,default_height); var image_data_proc= copyImageData(ctx,image_data); var gray_img=new jsfeat.matrix_t(default_width,default_height,jsfeat.U8_t|jsfeat.C1_t); jsfeat.imgproc.grayscale(image_data.data,gray_img.data); var data_u32 = new Uint32Array(image_data.data); var alpha = (0xff << 24); var i = gray_img.cols*gray_img.rows, pix = 0; while(--i >= 0) { pix =gray_img.data[i]; data_u32[i] = alpha | (pix << 16) | (pix << 8) | pix; } ctxImProc.putImageData(image_data,0,0);
Does the library currently only support image from webcam ? Or is this the "support for RGB/BGR order" that needs to be added ?
Thank you.