fix: 修改辅助图片判断
This commit is contained in:
parent
8755b70705
commit
3b1624f49a
@ -9,6 +9,7 @@ import android.content.pm.ActivityInfo;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Matrix;
|
||||
import android.location.Location;
|
||||
import android.media.MediaPlayer;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
@ -459,7 +460,10 @@ public class AutoTakePicture4PoiVideoActivity extends BaseActivity implements Vi
|
||||
@Override
|
||||
public void onMapClick(LatLng latLng) {
|
||||
Message msg = handler.obtainMessage(0x105);
|
||||
msg.obj = TencentLocationObtain.obtainTecentLocation(latLng);
|
||||
Location location = new Location("GPS");
|
||||
location.setLongitude(latLng.getLongitude());
|
||||
location.setLatitude(latLng.getLatitude());
|
||||
msg.obj = TencentLocationObtain.obtainTecentLocation(location);
|
||||
handler.sendMessage(msg);
|
||||
}
|
||||
});
|
||||
|
@ -49,6 +49,7 @@ import com.navinfo.outdoor.util.GeometryTools;
|
||||
import com.navinfo.outdoor.util.LocationLifeCycle;
|
||||
import com.navinfo.outdoor.util.MyLocation;
|
||||
import com.navinfo.outdoor.util.MyTecentLocationSource;
|
||||
import com.navinfo.outdoor.util.PictureCheckHelper;
|
||||
import com.navinfo.outdoor.util.SensorOritationLifecycle;
|
||||
import com.navinfo.outdoor.util.PicturesSpeedCheck;
|
||||
import com.navinfo.outdoor.util.SystemTTS;
|
||||
@ -95,6 +96,7 @@ import java.io.File;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -103,6 +105,7 @@ import java.util.Objects;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.ToIntFunction;
|
||||
|
||||
import static com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE;
|
||||
|
||||
@ -164,6 +167,7 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
|
||||
private SensorOritationLifecycle sensorOritationLifecycle;
|
||||
private TextView tvDegrees;
|
||||
private PicturesSpeedCheck speedCheck;
|
||||
private PictureCheckHelper pictureCheckHelper; // 照片辅助检查帮助类
|
||||
private Handler handler = new Handler(new Handler.Callback() {
|
||||
@Override
|
||||
public boolean handleMessage(@NonNull Message msg) {
|
||||
@ -205,6 +209,7 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
|
||||
}
|
||||
});
|
||||
speedCheck = new PicturesSpeedCheck();
|
||||
pictureCheckHelper = new PictureCheckHelper();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -460,15 +465,45 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
|
||||
public void onNext(Map map) {
|
||||
int index = Integer.parseInt(map.get("index").toString());
|
||||
PictureResult pictureResult = (PictureResult) map.get("picture");
|
||||
// 记录当前完成多少个图片的处理
|
||||
// 开始ocr文字识别
|
||||
List<OcrViewResultModel> ocrViewResultModels = OCRManager.Companion.getInstance().ocr(BitmapUtil.getBitmapFromBytes(pictureResult.getData()));
|
||||
if (ocrViewResultModels!=null&&!ocrViewResultModels.isEmpty()) {
|
||||
// 该照片存在文字信息,获取占比最大的文字,为后续POI判定做准备
|
||||
// 如果当前拍照是POI拍照模式,才需要做ocr识别以及附近POI查询
|
||||
if (type == 3) {
|
||||
// 开始ocr文字识别
|
||||
List<OcrViewResultModel> ocrViewResultModels = OCRManager.Companion.getInstance().ocr(BitmapUtil.getBitmapFromBytes(pictureResult.getData()));
|
||||
if (ocrViewResultModels!=null&&!ocrViewResultModels.isEmpty()) {
|
||||
pictureCheckHelper.addocrCheck(true);
|
||||
// 该照片存在文字信息,获取占比最大的文字,为后续POI判定做准备
|
||||
OcrViewResultModel maxOcrViewResult = ocrViewResultModels.stream()
|
||||
.max(new Comparator<OcrViewResultModel>() {
|
||||
@Override
|
||||
public int compare(OcrViewResultModel t0, OcrViewResultModel t1) {
|
||||
int t0Value = Math.abs(t0.getBounds().get(2).x-t0.getBounds().get(0).x)
|
||||
* Math.abs(t0.getBounds().get(2).y-t0.getBounds().get(0).y);
|
||||
int t1Value = Math.abs(t1.getBounds().get(2).x-t1.getBounds().get(0).x)
|
||||
* Math.abs(t1.getBounds().get(2).y-t1.getBounds().get(0).y);
|
||||
if (t0Value>t1Value) {
|
||||
return 1;
|
||||
} else if (t0Value<t1Value){
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
})
|
||||
.get();
|
||||
// 周边搜索,判定周边POI是否存在
|
||||
if (pictureCheckHelper.getCheckResult().getNearestChecked()<3) {
|
||||
// 发送请求,查询周边POI是否存在
|
||||
}
|
||||
} else {
|
||||
pictureCheckHelper.addocrCheck(false);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取当前手机姿态,判定该照片手机姿态是否合格
|
||||
float yDegree = sensorOritationLifecycle.getYDegree();
|
||||
// 周边搜索,判定周边POI是否存在
|
||||
if (yDegree>-90-45&&yDegree<-90+45) {
|
||||
|
||||
}
|
||||
// 记录当前完成多少个图片的处理
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,45 @@
|
||||
package com.navinfo.outdoor.util
|
||||
|
||||
/**
|
||||
* 照片辅助检查工具类
|
||||
* */
|
||||
class PictureCheckHelper {
|
||||
val checkResult = CheckResult()
|
||||
|
||||
fun addocrCheck(result: Boolean) {
|
||||
if (result) checkResult.ocrChecked++
|
||||
checkResult.ocrCount++
|
||||
}
|
||||
|
||||
fun addAngleCheck(result: Boolean) {
|
||||
if (result) checkResult.angleChecked++
|
||||
checkResult.angleCount++
|
||||
}
|
||||
|
||||
fun addNearestCheck(result: Boolean) {
|
||||
if (result) checkResult.nearestChecked++
|
||||
checkResult.nearestCount++
|
||||
}
|
||||
|
||||
fun addSpeedCheck(result: Boolean) {
|
||||
if (result) checkResult.speedChecked++
|
||||
checkResult.speedCount++
|
||||
}
|
||||
inner class CheckResult {
|
||||
// ocr检查结果
|
||||
var ocrChecked: Int = 0
|
||||
var ocrCount: Int = 0
|
||||
|
||||
// 方向检查结果,判断手机姿态
|
||||
var angleChecked = 0
|
||||
var angleCount = 0
|
||||
|
||||
// 附近POI查询结果
|
||||
var nearestChecked = 0
|
||||
var nearestCount = 0
|
||||
|
||||
// 速度检查结果
|
||||
var speedChecked = 0
|
||||
var speedCount = 0
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user