我做了物体探测。我把它放在边界框里了。我在边界框内裁剪。但它不起作用在调试模式下,它卡在if行上。谢谢!
result.setLocation(location);
mappedRecognitions.add(result);
if ((int) location.left > 0 && (int) location.top > 0 && ((int) location.left + (int) location.width()) < xyBitmap.getWidth()
&& ((int) location.top + (int) location.height()) < xyBitmap.getHeight()) {
mycroppedBitmap = Bitmap.createBitmap(xyBitmap,
(int) location.left,
(int) location.top,
(int) location.width(),
(int) location.height()
);
mycroppedBitmap = Bitmap.createScaledBitmap(mycroppedBitmap, 224, 224, true);
坐标
DetectorActivity.java 文件
https://github.com/usertttwm/CropAndClassificationModel/blob/main/DetectorActivity.java
对于修剪后的分类:TFLiteObjectDetectionAPIModel.java
https://github.com/usertttwm/CropAndClassificationModel/blob/main/TFLiteObjectDetectionAPIModel
NEW!!!!!
if (1==1) {
mycroppedBitmap = Bitmap.createBitmap(croppedBitmap,
1,1,224,224
);
final String resultLabel = detector1.recognizeImage1(mycroppedBitmap);
结果裁剪位图
mycroppedBitmap
DETECTIVE(我正在尝试裁剪边界框)
更新!!!!!!!!!!!!!!!!!!!!!!
mappedRecognitions.add(result);//TRAY DETECTIVE
Bitmap copyOfOriginalBitmap = rgbFrameBitmap.copy(rgbFrameBitmap.getConfig(), true);
Bitmap secondBitmap = Bitmap.createBitmap(copyOfOriginalBitmap,
(int) location.left, (int)location.top, (int)location.right, (int)location.bottom);
Bitmap secondScaledBitmap = Bitmap.createScaledBitmap(secondBitmap, 224, 224, true);
final String resultLabel = detector1.recognizeImage1(secondScaledBitmap);
作物工作更新
result.setLocation(location);
mappedRecognitions.add(result);
Bitmap copyOfOriginalBitmap = rgbFrameBitmap.copy(rgbFrameBitmap.getConfig(), true);
Bitmap secondBitmap = Bitmap.createBitmap(copyOfOriginalBitmap,
(int)location.left, (int)location.top, (int)location.right-(int)location.left, (int)location.bottom-(int)location.top);
Bitmap secondScaledBitmap = Bitmap.createScaledBitmap(secondBitmap, 224, 224, true);
final String resultLabel = detector1.recognizeImage1(secondScaledBitmap);
CROP
------------------资源-------------
https://github.com/AarohiSingla/TFLite-Object-Detection-Android-App-Tutorial-Using-YOLOv5我用它来检测yolo的物体。
https://www.youtube.com/watch?v=ZepT3N6aNFM&t=881shttps://github.com/ivangrov/TensorFlow-Lite-Age-Gender-Estimation-on-Android/blob/main/tflite/TFLiteObjectDetectionAPIModel.java
我用它来通过作物和分类模型。
1条答案
按热度按时间rsl1atfo1#
如果没有你提供的代码和信息,调试这个有点困难,但是这里有一些关于我如何解决这个问题的清晰步骤,也许你可以检查一下你的bug在哪里。我能看到的是,你试图从第一个裁剪的图像中裁剪第二个图像,这是错误的,你应该尝试从原始图像中裁剪第二个解释器的图像,所以这个过程应该看起来像这样:
1.首先创建一个原始位图的副本(因为您正在缩小它)
1.在你运行第一个解释器(使用originalBitmap)之后,你会得到坐标的范围是从0到解释器输入的宽度或高度(这可以改变,在你的日志中,我看到坐标被放大了,这是我们需要的)
你应该可以走了。