Closed GoogleCodeExporter closed 9 years ago
Just try to
IplImage imageBGR = IplImage.create(imageWidth, imageHeight, IPL_DEPTH_8U, 3);
cvCvtColor(image,imageBGR,CV_YUV2BGR_NV21);
but video is greenish.
Original comment by geuma...@gmail.com
on 14 Jun 2013 at 12:39
cvSetImageROI() won't work on planar images, that's normal. You'll need to
convert that to RGB beforehand.
How do you create the `image` that you use in
cvCvtColor(image,imageBGR,CV_YUV2BGR_NV21); ?
Original comment by samuel.a...@gmail.com
on 16 Jun 2013 at 2:02
Thanks : ),
this way I'm create the 'image'
IplImage image = IplImage.create(imageWidth, imageHeight*3/2, IPL_DEPTH_8U, 2);
Original comment by geuma...@gmail.com
on 17 Jun 2013 at 2:21
Just found this solution
http://stackoverflow.com/questions/12644627/android-javacv-create-iplimage-from-
camera-to-use-with-colorhistogram
It's worked!, but this is the best way?
Many thanks!
Original comment by geuma...@gmail.com
on 17 Jun 2013 at 3:14
Thanks for pointing me back to my answer :) But it was not correct. I've edited
to the following "best way", which should work, but again not tested:
IplImage imageYUV = IplImage.create(imageWidth, imageHeight * 3 / 2, IPL_DEPTH_8U, 2);
IplImage imageBGR = IplImage.create(imageWidth, imageHeight, IPL_DEPTH_8U, 3);
cvCvtColor(imageYUV, imageBGR, CV_YUV2BGR_NV21);
Let me know if you have any problems with that, and please ask your questions
on the mailing list next time if possible, thanks you!
Original comment by samuel.a...@gmail.com
on 22 Jun 2013 at 4:15
Thanks!
but it's not work, just greenish like Attach file.
Original comment by geuma...@gmail.com
on 25 Jun 2013 at 3:36
Attachments:
What code are you using?
Original comment by samuel.a...@gmail.com
on 29 Jun 2013 at 1:25
[deleted comment]
decode yuv420sp to rgb before cropImage and rotateImage..
cvSetImageROI not clearly work on yuv format image..
...
public void onPreviewFrame(byte[] data, Camera camera) {
...
int[] _temp = new int[imageWidth * imageHeight];
decodeYUV420SP(_temp, data, imageWidth, imageHeight);
IplImage image = IplImage.create(imageWidth, imageHeight, IPL_DEPTH_8U, 4);
image.getIntBuffer().put(_temp);
cvSetImageROI(image, new CvRect(...));
...
}
...
public static void decodeYUV420SP(int[] rgb, byte[] yuv420sp, int width, int
height) {
int frameSize = width * height;
for (int j = 0, yp = 0; j < height; j++) {
int uvp = frameSize + (j >> 1) * width, u = 0, v = 0;
for (int i = 0; i < width; i++, yp++) {
int y = (0xff & ((int) yuv420sp[yp])) - 16;
if (y < 0) y = 0;
if ((i & 1) == 0) {
v = (0xff & yuv420sp[uvp++]) - 128;
u = (0xff & yuv420sp[uvp++]) - 128;
}
int y1192 = 1192 * y;
int r = (y1192 + 1634 * v);
int g = (y1192 - 833 * v - 400 * u);
int b = (y1192 + 2066 * u);
if (r < 0) r = 0; else if (r > 262143) r = 262143;
if (g < 0) g = 0; else if (g > 262143) g = 262143;
if (b < 0) b = 0; else if (b > 262143) b = 262143;
rgb[yp] = 0xff000000 | ((b << 6) & 0xff0000) | ((g >> 2) & 0xff00) | ((r >> 10) & 0xff);
}
}
}
Original comment by g.wig...@gmail.com
on 29 Jul 2013 at 2:38
No it doesn't unfortunately... We need to convert it to RGB first.
Original comment by samuel.a...@gmail.com
on 15 Aug 2013 at 3:19
Is that solved?
Original comment by omur.ir...@gmail.com
on 21 Oct 2013 at 1:27
Converting it to RGB didn't solve the problem, still green pictures. I'm
looking for a solution.
Original comment by omur.ir...@gmail.com
on 21 Oct 2013 at 5:18
@omur Can you provide the few lines of code you are using? Thanks
Original comment by samuel.a...@gmail.com
on 3 Nov 2013 at 1:56
hi ,
how did you find the solution for same,
Can you give me some hint
Thanks
Original comment by Bindal...@gmail.com
on 25 Nov 2013 at 9:33
Guys, if you are having a problem with a piece code, we cannot solve the
problem if you do not provide the piece of code in question! Please copy/paste
the piece of code you are executing and that isn't working as it should, thank
you.
Original comment by samuel.a...@gmail.com
on 26 Nov 2013 at 6:04
Original issue reported on code.google.com by
geuma...@gmail.com
on 14 Jun 2013 at 11:47Attachments: