Android Developers pinned «OpenCV Image2Grayscale Converter Sketchware Pro Project»
What Did You Feel About The OpenCV Tutorial
Final Results
72%
I Really Like It I Want To Continue Learning
17%
I Don't Want To Continue Learning Please Stop The Tutorial
10%
In Comment
👍1
How To Resize Image Using OpenCV
To Resize Image Using OpenCV Follow The Following Steps.
Step1. In The View Area Add ImageView Or Any Other Image Displaying View.
Step2. Make Sure You Select OpenCV Android SDK In The Library Manager.
Step3. In The Custom Imports Add The Following Classes From OpenCV.
Step4. Load OpenCV C++ Binary Using The Following Code.
Step5. In Any Event You Want(OnCreate, OnButton Click Or Any Other Event) Where You Want To Resize The Image Use This Code. Read Comment's For Better Understanding.
To Resize Image Using OpenCV Follow The Following Steps.
Step1. In The View Area Add ImageView Or Any Other Image Displaying View.
Step2. Make Sure You Select OpenCV Android SDK In The Library Manager.
Step3. In The Custom Imports Add The Following Classes From OpenCV.
import org.opencv.core.Mat;
import org.opencv.core.Size;
import org.opencv.android.Utils;
import android.graphics.Bitmap;
import org.opencv.imgproc.Imgproc;
import org.opencv.imgcodecs.Imgcodecs;
import android.graphics.drawable.BitmapDrawable;
Step4. Load OpenCV C++ Binary Using The Following Code.
}
static {
System.loadLibrary("opencv_java4");
}
{
Step5. In Any Event You Want(OnCreate, OnButton Click Or Any Other Event) Where You Want To Resize The Image Use This Code. Read Comment's For Better Understanding.
//Get Bitmap From ImageView Called imageview1
Bitmap bitmap = ((BitmapDrawable) imageview1.getDrawable()).getBitmap();
//Initialize Mat Object For The Bitmap
Mat mat = new Mat();
//Convert The Bitmap From imageview1 To OpenCV Mat Object.
Utils.bitmapToMat(bitmap, mat);
//Initialize Mat Object For The Resized Image
Mat resizedmat = new Mat();
//Resize The Image From Mat Object With New Width 512 & Height 512
Imgproc.resize(mat, resizedmat, new Size(seekbar1.getProgress(), seekbar1.getProgress()));
//Create Bitmap From The Resized Mat Object Columns & Rows.
Bitmap resizedbitmap = Bitmap.createBitmap(resizedmat.cols(), resizedmat.rows(), Bitmap.Config.ARGB_8888);
//Convert The Resized Mat Object To Bitmap
Utils.matToBitmap(resizedmat, resizedbitmap);
//Display The Resized Bitmap In imageview1
imageview1.setImageBitmap(resizedbitmap);
//Release The Mat Objects To Prevent Memory Leaks
mat.release();
resizedmat.release();
Android Developers YouTube Channel Reaches 40 Subscribers.
😊 Thank You 😊
@SE_BIBEL_MEK
👉 @androiddevstutorial
😊 Thank You 😊
@SE_BIBEL_MEK
👉 @androiddevstutorial
👍2