FeiGeChuanShu / ncnn-android-yolov8

Real time yolov8 Android demo by ncnn
408 stars 83 forks source link

Input Image insted of liveCamera #16

Open ISTIAKPAPPU opened 1 year ago

ISTIAKPAPPU commented 1 year ago

Could you help me incorporate an image input into the model, resulting in an output that includes bounding boxes? i tried like this but not wroked

MainActivity=> public void PassImage() { Bitmap selectbp = imageViewToBitmap(imageView); // src to mat Mat mat_selectbp = new Mat(); Utils.bitmapToMat(selectbp, mat_selectbp); // target mat Mat newImg = Mat.zeros(new Size(selectbp.getWidth(), selectbp.getHeight()), CvType.CV_8UC3); model.processImage(mat_selectbp.getNativeObjAddr(), newImg.getNativeObjAddr());

    // target mat to bitmap
    Bitmap selectbp2 = Bitmap.createBitmap(newImg.cols(), newImg.rows(), selectbp.getConfig());
    Utils.matToBitmap(newImg, selectbp2);
    imageView.setVisibility(View.GONE);
    imageView2.setImageBitmap(selectbp2);
}

yolov8nncnn.cpp=> JNIEXPORT void JNICALL Java_com_example_appcpp_appcpp_processImage(JNIEnv env, jobject thiz, jlong mat_addr, jlong target_addr) { cv::Mat img = (cv::Mat ) mat_addr; cv::Mat &targetImg = (cv::Mat *) target_addr; targetImg = img.clone(); if (g_yolo ) {

    std::vector<Object> objects;
    g_yolo->detect(targetImg, objects);
    __android_log_print(ANDROID_LOG_DEBUG, "----detect--- ", "detectobject size %d",
                        objects.size());
    g_yolo->draw(targetImg, objects);
    __android_log_print(ANDROID_LOG_DEBUG, "----draw--- ", "drawobject size %d",
                        objects.size());
} else {
    draw_unsupported(targetImg);
}

}

NovaShen555 commented 11 months ago
  1. try using java take the pic and save
  2. pass the filepath to cpp function
  3. use cv::imread open the pic to cv::mat
  4. use function detect and draw
  5. use cv::imwrite save the result
jiuxiaying commented 6 months ago

Could you help me incorporate an image input into the model, resulting in an output that includes bounding boxes?您能否帮助我将图像输入合并到模型中,从而生成包含边界框的输出? i tried like this but not wroked我试过这样,但没有被拧干

MainActivity=> public void PassImage() {公共 void PassImage() { Bitmap selectbp = imageViewToBitmap(imageView);位图 SelectBop = ImageViewMap(ImageView); // src to matsrc 为 mat Mat mat_selectbp = new Mat();vote_selectub = 新投票(); Utils.bitmapToMat(selectbp, mat_selectbp);Utils.bitmapToMat (selectbp, mat_selectbp); // target mat 哑光目标 Mat newImg = Mat.zeros(new Size(selectbp.getWidth(), selectbp.getHeight()), CvType.CV_8UC3);垫 newImg = Mat.zeros(new Size(selectbp.getWidth(), selectbp.getHeight()), CvType.CV_8UC3); model.processImage(mat_selectbp.getNativeObjAddr(), newImg.getNativeObjAddr());model.processImage(mat_selectbp.getNativeObjAddr(), newImg.getNativeObjAddr());

    // target mat to bitmap
    Bitmap selectbp2 = Bitmap.createBitmap(newImg.cols(), newImg.rows(), selectbp.getConfig());
    Utils.matToBitmap(newImg, selectbp2);
    imageView.setVisibility(View.GONE);
    imageView2.setImageBitmap(selectbp2);
}

yolov8nncnn.cpp=> yolov8nenn.cpp=> JNIEXPORT void JNICALL JNIEEXPORT 无效 JNICL Java_com_example_appcpp_appcpp_processImage(JNIEnv env, jobject thiz, jlong mat_addr,Java_com_example_appcpp_appcpp_processImage(JNIEnv env, jobject thiz, jlong mat_addr, jlong target_addr) { jlong target_addr) { cv::Mat img = (cv::Mat ) mat_addr;cv::Mat img = (cv::Mat ) mat_addr; cv::Mat &targetImg = (cv::Mat ) target_addr;cv::Mat &targetImg = (cv::Mat ) target_addr; targetImg = img.clone();目标Img = img.clone(); if (g_yolo ) {如果 (g_yolo ) {

    std::vector<Object> objects;
    g_yolo->detect(targetImg, objects);
    __android_log_print(ANDROID_LOG_DEBUG, "----detect--- ", "detectobject size %d",
                        objects.size());
    g_yolo->draw(targetImg, objects);
    __android_log_print(ANDROID_LOG_DEBUG, "----draw--- ", "drawobject size %d",
                        objects.size());
} else {
    draw_unsupported(targetImg);
}

}

Hello, have you solved it? Can you tell me how to achieve it?

NovaShen555 commented 6 months ago

Could you help me incorporate an image input into the model, resulting in an output that includes bounding boxes?您能否帮助我将图像输入合并到模型中,从而生成包含边界框的输出? i tried like this but not wroked我试过这样,但没有被拧干 MainActivity=> public void PassImage() {公共 void PassImage() { Bitmap selectbp = imageViewToBitmap(imageView);位图 SelectBop = ImageViewMap(ImageView); // src to matsrc 为 mat Mat mat_selectbp = new Mat();vote_selectub = 新投票(); Utils.bitmapToMat(selectbp, mat_selectbp);Utils.bitmapToMat (selectbp, mat_selectbp); // target mat 哑光目标 Mat newImg = Mat.zeros(new Size(selectbp.getWidth(), selectbp.getHeight()), CvType.CV_8UC3);垫 newImg = Mat.zeros(new Size(selectbp.getWidth(), selectbp.getHeight()), CvType.CV_8UC3); model.processImage(mat_selectbp.getNativeObjAddr(), newImg.getNativeObjAddr());model.processImage(mat_selectbp.getNativeObjAddr(), newImg.getNativeObjAddr());

    // target mat to bitmap
    Bitmap selectbp2 = Bitmap.createBitmap(newImg.cols(), newImg.rows(), selectbp.getConfig());
    Utils.matToBitmap(newImg, selectbp2);
    imageView.setVisibility(View.GONE);
    imageView2.setImageBitmap(selectbp2);
}

yolov8nncnn.cpp=> yolov8nenn.cpp=> JNIEXPORT void JNICALL JNIEEXPORT 无效 JNICL Java_com_example_appcpp_appcpp_processImage(JNIEnv env, jobject thiz, jlong mat_addr,Java_com_example_appcpp_appcpp_processImage(JNIEnv env, jobject thiz, jlong mat_addr, jlong target_addr) { jlong target_addr) { cv::Mat img = (cv::Mat ) mat_addr;cv::Mat img = (cv::Mat ) mat_addr; cv::Mat &targetImg = (cv::Mat ) target_addr;cv::Mat &targetImg = (cv::Mat ) target_addr; targetImg = img.clone();目标Img = img.clone(); if (g_yolo ) {如果 (g_yolo ) {

    std::vector<Object> objects;
    g_yolo->detect(targetImg, objects);
    __android_log_print(ANDROID_LOG_DEBUG, "----detect--- ", "detectobject size %d",
                        objects.size());
    g_yolo->draw(targetImg, objects);
    __android_log_print(ANDROID_LOG_DEBUG, "----draw--- ", "drawobject size %d",
                        objects.size());
} else {
    draw_unsupported(targetImg);
}

}

Hello, have you solved it? Can you tell me how to achieve it?

看我回复

jiuxiaying commented 6 months ago

Could you help me incorporate an image input into the model, resulting in an output that includes bounding boxes?您能否帮助我将图像输入合并到模型中,从而生成包含边界框的输出? i tried like this but not wroked我试过这样,但没有被拧干 MainActivity=> public void PassImage() {公共 void PassImage() { Bitmap selectbp = imageViewToBitmap(imageView);位图 SelectBop = ImageViewMap(ImageView); // src to matsrc 为 mat Mat mat_selectbp = new Mat();vote_selectub = 新投票(); Utils.bitmapToMat(selectbp, mat_selectbp);Utils.bitmapToMat (selectbp, mat_selectbp); // target mat 哑光目标 Mat newImg = Mat.zeros(new Size(selectbp.getWidth(), selectbp.getHeight()), CvType.CV_8UC3);垫 newImg = Mat.zeros(new Size(selectbp.getWidth(), selectbp.getHeight()), CvType.CV_8UC3); model.processImage(mat_selectbp.getNativeObjAddr(), newImg.getNativeObjAddr());model.processImage(mat_selectbp.getNativeObjAddr(), newImg.getNativeObjAddr());MainActivity=> public void PassImage() {公共 void PassImage() { Bitmap selectbp = imageViewToBitmap(imageView);位图 SelectBop = ImageViewMap(ImageView);src to matsrc 为 mat Mat mat_selectbp = new Mat();vote_selectub = 新投票();Utils.bitmapToMat(selectbp, mat_selectbp);Utils.bitmapToMat (selectbp, mat_selectbp);target mat 哑光目标 Mat newImg = Mat.zeros(new Size(selectbp.getWidth(), selectbp.getHeight()), CvType.CV_8UC3);垫 newImg = Mat.zeros(new Size(selectbp.getWidth(), selectbp.getHeight()), CvType.CV_8UC3);model.processImage(mat_selectbp.getNativeObjAddr(), newImg.getNativeObjAddr());model.processImage(mat_selectbp.getNativeObjAddr(), newImg.getNativeObjAddr());

    // target mat to bitmap
    Bitmap selectbp2 = Bitmap.createBitmap(newImg.cols(), newImg.rows(), selectbp.getConfig());
    Utils.matToBitmap(newImg, selectbp2);
    imageView.setVisibility(View.GONE);
    imageView2.setImageBitmap(selectbp2);
}

yolov8nncnn.cpp=> yolov8nenn.cpp=> JNIEXPORT void JNICALL JNIEEXPORT 无效 JNICL Java_com_example_appcpp_appcpp_processImage(JNIEnv env, jobject thiz, jlong mat_addr,Java_com_example_appcpp_appcpp_processImage(JNIEnv env, jobject thiz, jlong mat_addr, jlong target_addr) { jlong target_addr) { cv::Mat img = (cv::Mat ) mat_addr;cv::Mat img = (cv::Mat ) mat_addr; cv::Mat &targetImg = (cv::Mat ) target_addr;cv::Mat &targetImg = (cv::Mat ) target_addr; targetImg = img.clone();目标Img = img.clone(); if (g_yolo ) {如果 (g_yolo ) {

    std::vector<Object> objects;
    g_yolo->detect(targetImg, objects);
    __android_log_print(ANDROID_LOG_DEBUG, "----detect--- ", "detectobject size %d",
                        objects.size());
    g_yolo->draw(targetImg, objects);
    __android_log_print(ANDROID_LOG_DEBUG, "----draw--- ", "drawobject size %d",
                        objects.size());
} else {
    draw_unsupported(targetImg);
}

}

Hello, have you solved it? Can you tell me how to achieve it?

看我回复

已经解决谢谢!

mengxizeng commented 5 months ago

Could you help me incorporate an image input into the model, resulting in an output that includes bounding boxes?您能否帮助我将图像输入合并到模型中,从而生成包含边界框的输出? i tried like this but not wroked我试过这样,但没有被拧干 MainActivity=> public void PassImage() {公共 void PassImage() { Bitmap selectbp = imageViewToBitmap(imageView);位图 SelectBop = ImageViewMap(ImageView); // src to matsrc 为 mat Mat mat_selectbp = new Mat();vote_selectub = 新投票(); Utils.bitmapToMat(selectbp, mat_selectbp);Utils.bitmapToMat (selectbp, mat_selectbp); // target mat 哑光目标 Mat newImg = Mat.zeros(new Size(selectbp.getWidth(), selectbp.getHeight()), CvType.CV_8UC3);垫 newImg = Mat.zeros(new Size(selectbp.getWidth(), selectbp.getHeight()), CvType.CV_8UC3); model.processImage(mat_selectbp.getNativeObjAddr(), newImg.getNativeObjAddr());model.processImage(mat_selectbp.getNativeObjAddr(), newImg.getNativeObjAddr());MainActivity=> public void PassImage() {公共 void PassImage() { Bitmap selectbp = imageViewToBitmap(imageView);位图 SelectBop = ImageViewMap(ImageView);src to matsrc 为 mat Mat mat_selectbp = new Mat();vote_selectub = 新投票();Utils.bitmapToMat(selectbp, mat_selectbp);Utils.bitmapToMat (selectbp, mat_selectbp);target mat 哑光目标 Mat newImg = Mat.zeros(new Size(selectbp.getWidth(), selectbp.getHeight()), CvType.CV_8UC3);垫 newImg = Mat.zeros(new Size(selectbp.getWidth(), selectbp.getHeight()), CvType.CV_8UC3);model.processImage(mat_selectbp.getNativeObjAddr(), newImg.getNativeObjAddr());model.processImage(mat_selectbp.getNativeObjAddr(), newImg.getNativeObjAddr());

    // target mat to bitmap
    Bitmap selectbp2 = Bitmap.createBitmap(newImg.cols(), newImg.rows(), selectbp.getConfig());
    Utils.matToBitmap(newImg, selectbp2);
    imageView.setVisibility(View.GONE);
    imageView2.setImageBitmap(selectbp2);
}

yolov8nncnn.cpp=> yolov8nenn.cpp=> JNIEXPORT void JNICALL JNIEEXPORT 无效 JNICL Java_com_example_appcpp_appcpp_processImage(JNIEnv env, jobject thiz, jlong mat_addr,Java_com_example_appcpp_appcpp_processImage(JNIEnv env, jobject thiz, jlong mat_addr, jlong target_addr) { jlong target_addr) { cv::Mat img = (cv::Mat ) mat_addr;cv::Mat img = (cv::Mat ) mat_addr; cv::Mat &targetImg = (cv::Mat ) target_addr;cv::Mat &targetImg = (cv::Mat ) target_addr; targetImg = img.clone();目标Img = img.clone(); if (g_yolo ) {如果 (g_yolo ) {

    std::vector<Object> objects;
    g_yolo->detect(targetImg, objects);
    __android_log_print(ANDROID_LOG_DEBUG, "----detect--- ", "detectobject size %d",
                        objects.size());
    g_yolo->draw(targetImg, objects);
    __android_log_print(ANDROID_LOG_DEBUG, "----draw--- ", "drawobject size %d",
                        objects.size());
} else {
    draw_unsupported(targetImg);
}

}

Hello, have you solved it? Can you tell me how to achieve it?

看我回复

已经解决谢谢!

您好,请问你是怎么做的。

ISTIAKPAPPU commented 5 months ago

I used yolov5 demo and edit some script for yolov8 in android studio I used implementation 'org.pytorch:pytorch_android_lite:1.12.2' implementation 'org.pytorch:pytorch_android_torchvision_lite:1.12.2'

insted of OpenCV

On Mon, 13 May, 2024 at 12:58 PM, mengxizeng @.***> wrote:

Could you help me incorporate an image input into the model, resulting in an output that includes bounding boxes?您能否帮助我将图像输入合并到模型中,从而生成包含边界框的输出? i tried like this but not wroked我试过这样,但没有被拧干 MainActivity=> public void PassImage() {公共 void PassImage() { Bitmap selectbp = imageViewToBitmap(imageView);位图 SelectBop = ImageViewMap(ImageView); // src to matsrc 为 mat Mat mat_selectbp = new Mat();vote_selectub = 新投票(); Utils.bitmapToMat(selectbp, mat_selectbp);Utils.bitmapToMat (selectbp, mat_selectbp); // target mat 哑光目标 Mat newImg = Mat.zeros(new Size(selectbp.getWidth(), selectbp.getHeight()), CvType.CV_8UC3);垫 newImg = Mat.zeros(new Size(selectbp.getWidth(), selectbp.getHeight()), CvType.CV_8UC3); model.processImage(mat_selectbp.getNativeObjAddr(), newImg.getNativeObjAddr());model.processImage(mat_selectbp.getNativeObjAddr(), newImg.getNativeObjAddr());MainActivity=> public void PassImage() {公共 void PassImage() { Bitmap selectbp = imageViewToBitmap(imageView);位图 SelectBop = ImageViewMap(ImageView);src to matsrc 为 mat Mat mat_selectbp = new Mat();vote_selectub = 新投票();Utils.bitmapToMat(selectbp, mat_selectbp);Utils.bitmapToMat (selectbp, mat_selectbp);target mat 哑光目标 Mat newImg = Mat.zeros(new Size(selectbp.getWidth(), selectbp.getHeight()), CvType.CV_8UC3);垫 newImg = Mat.zeros(new Size(selectbp.getWidth(), selectbp.getHeight()), CvType.CV_8UC3);model.processImage(mat_selectbp.getNativeObjAddr(), newImg.getNativeObjAddr());model.processImage(mat_selectbp.getNativeObjAddr(), newImg.getNativeObjAddr());

// target mat to bitmap
Bitmap selectbp2 = Bitmap.createBitmap(newImg.cols(), newImg.rows(), selectbp.getConfig());
Utils.matToBitmap(newImg, selectbp2);
imageView.setVisibility(View.GONE);
imageView2.setImageBitmap(selectbp2);

}

yolov8nncnn.cpp=> yolov8nenn.cpp=> JNIEXPORT void JNICALL JNIEEXPORT 无效 JNICL Java_com_example_appcpp_appcpp_processImage(JNIEnv env, jobject thiz, jlong mat_addr,Java_com_example_appcpp_appcpp_processImage(JNIEnv env, jobject thiz, jlong mat_addr, jlong target_addr) { jlong target_addr) { cv::Mat img = (cv::Mat ) mat_addr;cv::Mat img = (cv::Mat ) mat_addr; cv::Mat &targetImg = (cv::Mat ) target_addr;cv::Mat &targetImg = (cv::Mat ) target_addr; targetImg = img.clone();目标Img = img.clone(); if (g_yolo ) {如果 (g_yolo ) {

std::vector<Object> objects;
g_yolo->detect(targetImg, objects);
__android_log_print(ANDROID_LOG_DEBUG, "----detect--- ", "detectobject size %d",
                    objects.size());
g_yolo->draw(targetImg, objects);
__android_log_print(ANDROID_LOG_DEBUG, "----draw--- ", "drawobject size %d",
                    objects.size());

} else { draw_unsupported(targetImg); }

}

Hello, have you solved it? Can you tell me how to achieve it?

看我回复

已经解决谢谢!

您好,请问你是怎么做的。

— Reply to this email directly, view it on GitHub https://github.com/FeiGeChuanShu/ncnn-android-yolov8/issues/16#issuecomment-2106794366, or unsubscribe https://github.com/notifications/unsubscribe-auth/AL3JT6S2Y75HF5Q22TNFK43ZCBQBDAVCNFSM6AAAAAAYGMHLB2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBWG44TIMZWGY . You are receiving this because you authored the thread.Message ID: @.***>

mengxizeng commented 5 months ago

I used yolov5 demo and edit sob script for yolo8 for android studio I didn’t used opencV On Mon, 13 May, 2024 at 12:58 PM, mengxizeng @.> wrote: Could you help me incorporate an image input into the model, resulting in an output that includes bounding boxes?您能否帮助我将图像输入合并到模型中,从而生成包含边界框的输出? i tried like this but not wroked我试过这样,但没有被拧干 MainActivity=> public void PassImage() {公共 void PassImage() { Bitmap selectbp = imageViewToBitmap(imageView);位图 SelectBop = ImageViewMap(ImageView); // src to matsrc 为 mat Mat mat_selectbp = new Mat();vote_selectub = 新投票(); Utils.bitmapToMat(selectbp, mat_selectbp);Utils.bitmapToMat (selectbp, mat_selectbp); // target mat 哑光目标 Mat newImg = Mat.zeros(new Size(selectbp.getWidth(), selectbp.getHeight()), CvType.CV_8UC3);垫 newImg = Mat.zeros(new Size(selectbp.getWidth(), selectbp.getHeight()), CvType.CV_8UC3); model.processImage(mat_selectbp.getNativeObjAddr(), newImg.getNativeObjAddr());model.processImage(mat_selectbp.getNativeObjAddr(), newImg.getNativeObjAddr());MainActivity=> public void PassImage() {公共 void PassImage() { Bitmap selectbp = imageViewToBitmap(imageView);位图 SelectBop = ImageViewMap(ImageView);src to matsrc 为 mat Mat mat_selectbp = new Mat();vote_selectub = 新投票();Utils.bitmapToMat(selectbp, mat_selectbp);Utils.bitmapToMat (selectbp, mat_selectbp);target mat 哑光目标 Mat newImg = Mat.zeros(new Size(selectbp.getWidth(), selectbp.getHeight()), CvType.CV_8UC3);垫 newImg = Mat.zeros(new Size(selectbp.getWidth(), selectbp.getHeight()), CvType.CV_8UC3);model.processImage(mat_selectbp.getNativeObjAddr(), newImg.getNativeObjAddr());model.processImage(mat_selectbp.getNativeObjAddr(), newImg.getNativeObjAddr()); // target mat to bitmap Bitmap selectbp2 = Bitmap.createBitmap(newImg.cols(), newImg.rows(), selectbp.getConfig()); Utils.matToBitmap(newImg, selectbp2); imageView.setVisibility(View.GONE); imageView2.setImageBitmap(selectbp2); } yolov8nncnn.cpp=> yolov8nenn.cpp=> JNIEXPORT void JNICALL JNIEEXPORT 无效 JNICL Java_com_example_appcpp_appcpp_processImage(JNIEnv env, jobject thiz, jlong mat_addr,Java_com_example_appcpp_appcpp_processImage(JNIEnv env, jobject thiz, jlong mat_addr, jlong target_addr) { jlong target_addr) { cv::Mat img = (cv::Mat ) mat_addr;cv::Mat img = (cv::Mat ) mat_addr; cv::Mat &targetImg = (cv::Mat ) target_addr;cv::Mat &targetImg = (cv::Mat ) target_addr; targetImg = img.clone();目标Img = img.clone(); if (g_yolo ) {如果 (g_yolo ) { std::vector objects; g_yolo->detect(targetImg, objects); __android_log_print(ANDROID_LOG_DEBUG, "----detect--- ", "detectobject size %d", objects.size()); g_yolo->draw(targetImg, objects); __android_log_print(ANDROID_LOG_DEBUG, "----draw--- ", "drawobject size %d", objects.size()); } else { draw_unsupported(targetImg); } } Hello, have you solved it? Can you tell me how to achieve it? 看我回复 已经解决谢谢! 您好,请问你是怎么做的。 — Reply to this email directly, view it on GitHub <#16 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AL3JT6S2Y75HF5Q22TNFK43ZCBQBDAVCNFSM6AAAAAAYGMHLB2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBWG44TIMZWGY . You are receiving this because you authored the thread.Message ID: @.>

The answer given by Chapter 4 @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == 1 && resultCode == RESULT_OK && data != null) { Uri imageUri = data.getData(); try { // 从 URI 直接加载 Bitmap Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), imageUri);

            // 确保 Bitmap 是可变的,如果不是,创建一个可变的复制
            if (!bitmap.isMutable()) {
                bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
            }
            ImageView imageView = (ImageView) findViewById(R.id.cameraview);
            Bitmap detectedImage = yolov8ncnn.detectImage(bitmap);
            imageView.setImageBitmap(detectedImage);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

JNIEXPORT jobject JNICALL Java_com_tencent_yolov8ncnn_Yolov8Ncnn_detectImage(JNIEnv env, jobject thiz, jobject bitmap) { AndroidBitmapInfo info; void bitmapPixels; cv::Mat img;

// 获取Bitmap信息和像素数据
if (AndroidBitmap_getInfo(env, bitmap, &info) < 0) {
    return NULL;
}

if (info.format != ANDROID_BITMAP_FORMAT_RGBA_8888) {
    return NULL;
}

if (AndroidBitmap_lockPixels(env, bitmap, &bitmapPixels) < 0) {
    return NULL;
}

// 创建一个OpenCV mat来操作像素
img = cv::Mat(info.height, info.width, CV_8UC4, bitmapPixels);
cv::cvtColor(img, img, cv::COLOR_RGBA2BGR);
std::vector<Object> objects;
// 进行检测和绘制操作
g_yolo->detect(img, objects);
__android_log_print(ANDROID_LOG_INFO, "YoloV8Ncnn", "Detected %d objects.", objects.size());

g_yolo->draw(img, objects);
__android_log_print(ANDROID_LOG_INFO, "YoloV8Ncnn", "draw %d objects",objects.size());

//cv::cvtColor(img, img, cv::COLOR_BGR2RGBA);
AndroidBitmap_unlockPixels(env, bitmap);
return bitmap;

} In this way, the main activity is achieved by passing in the bitmap and jni functions to perform image segmentation. After detection, there are also results, but no borders are drawn.