Hi techies,
Now iam gonna share a wonderful and efficient way on "How to convert IplImage to byte array in JavaCV" with pure java code.
How to convert IplImage to Android Bitmap
How to convert IplImage to byte[]
So hope you guys got this helper methods so useful for your JavaCV projects.
And don't forget to use the comment box below.
Now iam gonna share a wonderful and efficient way on "How to convert IplImage to byte array in JavaCV" with pure java code.
How to convert IplImage to Android Bitmap
public static Bitmap IplImageToBitmap(IplImage src) {
Bitmap bm=null;
int width = src.width();
int height = src.height();
// Unfortunately cvCvtColor will not let us convert in place, so we need to create a new IplImage with matching dimensions.
IplImage frame2 = IplImage.create(width, height, opencv_core.IPL_DEPTH_8U, 4);
opencv_imgproc.cvCvtColor(src, frame2, opencv_imgproc.CV_BGR2RGBA);
// Now we make an Android Bitmap with matching size ... Nb. at this point we functionally have 3 buffers == image size. Watch your memory usage!
bm = Bitmap.createBitmap(frame2.width(), frame2.height(), Bitmap.Config.ARGB_8888);
bm.copyPixelsFromBuffer(frame2.getByteBuffer());
//src.release();
frame2.release();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
return bm;
}
How to convert IplImage to byte[]
public static byte[] IplImageToByteArray(IplImage src) {
Bitmap bm=null;
int width = src.width();
int height = src.height();
// Unfortunately cvCvtColor will not let us convert in place, so we need to create a new IplImage with matching dimensions.
IplImage frame2 = IplImage.create(width, height, opencv_core.IPL_DEPTH_8U, 4);
opencv_imgproc.cvCvtColor(src, frame2, opencv_imgproc.CV_BGR2RGBA);
// Now we make an Android Bitmap with matching size ... Nb. at this point we functionally have 3 buffers == image size. Watch your memory usage!
bm = Bitmap.createBitmap(frame2.width(), frame2.height(), Bitmap.Config.ARGB_8888);
bm.copyPixelsFromBuffer(frame2.getByteBuffer());
//src.release();
frame2.release();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.PNG, 100, stream);
return stream.toByteArray();
}
So hope you guys got this helper methods so useful for your JavaCV projects.
And don't forget to use the comment box below.
Với nền kinh tế ngày càng phát triển, trên thị trường có hàng ngàn các sản phẩm hàng hóa đến từ các doanh nghiệp khác nhau. Chính vì vậy, để kinh doanh hiệu quả, ngoài chất lượng sản phẩm thì doanh nghiệp cũng cần chú ý thương hiệu, hình ảnh công ty. in tem decal đẹp, bắt mắt đã trở thành một công cụ marketing vô cùng hiệu quả được rất nhiều doanh nghiệp sử dụng.
BalasHapusBạn có nhu cầu in tem decal vui lòng liên hệ với in Đông Bắc để có những sản phẩm chất lượng nhất.
hotline: 0988291900
It’s really informative. I am going to watch out for brussels.
BalasHapusI’ll be grateful if you continue this in future. smartbytes Numerous people will be benefited from your writing.
Airtel USSD Codes
Cheers!
buy moonrock carts online
BalasHapusbuy juul accessories online
buy juul compatibles online
buy pre - filled vape cartridges online
prefiiled vape cartridges for sale
juul skin
buy juul skin online
buy disposable online
buy juul disposable online
buy pre rolls online
pre rolls for sale
order pre rolls online
buy CBD oil online
cbd oil for sale
order cbd oil online
Buy THC Oil Pre-filled Cartridges
CBD Vape Oil Cartridges for sale
THC Vape Shop Near me
buy dr zodiak moonrock clear carts flavors online
dr zodiak moonrock clear carts
buy refillable juul pods online
buy juulpds cucumber flavor online
juul-pod-creme-brulee
juul pods flavors for sale
buy GRAND DADDY PURP online
buy delta 8 carts online
delta 8 carts for sale
order delta 8 carts online
buy best delta 8 carts online
best delta 8 carts for sale
buy STRAWBERRY COUGH carts online
buy STRAWBERRY COUGH online
BalasHapusbuy CALI ORANGE KUSH online
buy CALI ORANGE KUSH carts online
CALI ORANGE KUSH for sale
buy delta effex carts online
buy STRAWBERRY CITRUS FULL SPECTRUM CBD CARTRIDGE online
buy MANGO CITRUS FULL SPECTRUM CBD PEN online
buy STRAWBERRY CITRUS CBD ISOLATE CARTRIDGE online
buy SWEET DREAMS FULL SPECTRUM CBD PEN online
buy STRAWBERRY LEMONADE CBD VAPE PEN BY CBDFX online
buy NATURAL FULL SPECTRUM CBD CARTRIDGE online
buy savage CBD vape carts online
buy savage CBD cartridges online
savage CBD carts for sale
order savage CBD carts online
buy CBD DISPOSABLE PENS & CARTRIDGES online
buy CBD pens and cartridges online