balabala~~~

This commit is contained in:
wangcongtao
2020-11-01 10:30:25 +08:00
parent 58bb6f3833
commit 513952a709
35 changed files with 258 additions and 76 deletions

View File

@@ -24,7 +24,7 @@ public class CustomMapView implements IMogoMapViewCreator {
@Override
public IMogoMapView create( Context context ) {
if ( mapView == null ) {
MapAutoApi.INSTANCE.init( context, MapParams.Companion.init().setDebugMode( true )
MapAutoApi.INSTANCE.init( context, MapParams.Companion.init().setDebugMode( false )
.setCoordinateType( MapParams.COORDINATETYPE_GCJ02 )
.setPerspectiveMode( MapParams.MAP_PERSPECTIVE_2D )
.setZoom( 16 )

View File

@@ -9,21 +9,21 @@ public
*/
enum AdasRecognizedType {
//背景
classIdBackground( "background",0 ),
classIdBackground( "background", 0 ),
//人
classIdPerson( "person",1 ),
classIdPerson( "person", 1 ),
//自行车
classIdBicycle( "bicycle",2 ),
classIdBicycle( "bicycle", 2 ),
//小轿车
classIdCar( "car",3 ),
classIdCar( "car", 3 ),
//摩托车
classIdMoto( "moto",4 ),
classIdMoto( "moto", 4 ),
//红绿灯
classIdTrafficSign( "traffic_sign",5 ),
classIdTrafficSign( "traffic_sign", 5 ),
//bus
classIdTrafficBus( "traffic_bus",6 ),
classIdTrafficBus( "traffic_bus", 6 ),
//track
classIdTrafficTruck( "traffic_truck",8 );
classIdTrafficTruck( "traffic_truck", 8 );
AdasRecognizedType( int code ) {
this.code = code;
@@ -42,6 +42,9 @@ enum AdasRecognizedType {
}
public static AdasRecognizedType valueFrom( int code ) {
if ( code == 0 ) {
return classIdCar;
}
for ( AdasRecognizedType value : AdasRecognizedType.values() ) {
if ( value.code == code ) {
return value;

View File

@@ -8,16 +8,22 @@ public
* 描述
*/
enum SafeType {
Normal( "安全" ),
SpeedWarm( "注意/超速" ),
DistanceWarm( "注意/保持车距" ),
SpeedDangerous( "危险/严重超速" ),
DistanceDangerous( "危险/距离过近" );
Normal( "normal", "安全" ),
SpeedWarm( "warm", "注意/超速" ),
DistanceWarm( "warm", "注意/保持车距" ),
SpeedDangerous( "dangerous", "危险/严重超速" ),
DistanceDangerous( "dangerous", "危险/距离过近" );
private String msg;
private String res;
SafeType( String msg ) {
SafeType( String res, String msg ) {
this.msg = msg;
this.res = res;
}
public String getRes() {
return res;
}
public String getMsg() {

View File

@@ -9,7 +9,7 @@ public
*/
enum VisionMode {
Machine( "user" ),
Machine( "machine" ),
User( "user" );
private String res;

View File

@@ -9,6 +9,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.data.BaseData;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
@@ -36,7 +37,7 @@ public
*
* 绘制adas近景识别到的车辆
*/
class AdasRecognizedResultDrawer {
class AdasRecognizedResultDrawer extends BaseDrawer {
private static volatile AdasRecognizedResultDrawer sInstance;
@@ -183,39 +184,17 @@ class AdasRecognizedResultDrawer {
private View inflateView( ADASRecognizedListResult data, boolean machineVision, double curSpeed ) {
View rootView = LayoutInflater.from( AbsMogoApplication.getApp() ).inflate( R.layout.module_commons_layout_car, null );
SafeType safeType = getSafeType( data, curSpeed );
SafeType safeType = getSafeType( data.distanceX, data.distanceY, data.speed, curSpeed );
TextView tv = rootView.findViewById( R.id.module_commons_marker_car_speed );
tv.setText( safeType.getMsg() );
ImageView iv = rootView.findViewById( R.id.module_commons_marker_car_model );
iv.setImageResource( MarkerResourceManager.getMarkerDrawableResId(
machineVision ? VisionMode.Machine : VisionMode.User,
AdasRecognizedType.valueFrom( data.type ),
getCarModelType()
getCarModelType(),
safeType
) );
return rootView;
}
private SafeType getSafeType( ADASRecognizedListResult data, double curSpeed ) {
if ( data == null ) {
return SafeType.Normal;
}
if ( data.distanceY < 0.5 || data.distanceY < 0.5 ) {
return SafeType.DistanceDangerous;
}
if ( data.speed > curSpeed * 1.5 ) {
return SafeType.SpeedDangerous;
}
if ( data.distanceY < 1 || data.distanceY < 1 ) {
return SafeType.DistanceDangerous;
}
if ( data.speed > curSpeed * 1.1 ) {
return SafeType.DistanceWarm;
}
return SafeType.Normal;
}
private CarModelType getCarModelType() {
return CarModelType.Self;
}
}

View File

@@ -0,0 +1,72 @@
package com.mogo.module.common.drawer;
import com.mogo.module.common.constants.CarModelType;
import com.mogo.module.common.constants.SafeType;
public
/**
* @author congtaowang
* @since 2020/10/30
* <p>
* 描述
*/
class BaseDrawer {
public static final double BOUND_DISTANCE_DANGEROUS = 0.5;
public static final double BOUND_SPEED_DANGEROUS = 1.5;
public static final double BOUND_DISTANCE_WARM = 1;
public static final double BOUND_SPEED_WARM = 1.1;
/**
* 安全类型
*
* @param distance
* @param speed
* @param curSpeed
* @return
*/
protected SafeType getSafeType( double distance, double speed, double curSpeed ) {
if ( distance < BOUND_DISTANCE_DANGEROUS ) {
return SafeType.DistanceDangerous;
}
if ( speed > curSpeed * BOUND_SPEED_DANGEROUS ) {
return SafeType.SpeedDangerous;
}
if ( distance < BOUND_DISTANCE_WARM ) {
return SafeType.DistanceDangerous;
}
if ( speed > curSpeed * BOUND_SPEED_WARM ) {
return SafeType.DistanceWarm;
}
return SafeType.Normal;
}
protected SafeType getSafeType( double distanceX, double distanceY, double speed, double curSpeed ) {
if ( distanceX < BOUND_DISTANCE_DANGEROUS || distanceY < BOUND_DISTANCE_DANGEROUS ) {
return SafeType.DistanceDangerous;
}
if ( speed > curSpeed * BOUND_SPEED_DANGEROUS ) {
return SafeType.SpeedDangerous;
}
if ( distanceX < BOUND_DISTANCE_WARM || distanceY < BOUND_DISTANCE_WARM ) {
return SafeType.DistanceWarm;
}
if ( speed > curSpeed * BOUND_SPEED_WARM ) {
return SafeType.SpeedWarm;
}
return SafeType.Normal;
}
/**
* 车模
*
* @return
*/
protected CarModelType getCarModelType() {
// 根据车道、行驶方向等计算出选用哪个车模图片
return CarModelType.Other;
}
}

View File

@@ -122,7 +122,9 @@ class MarkerDrawer {
if ( !existMap.containsKey( sn ) ) {
IMogoMarker dirtyMarker = allMap.get( sn );
allCarsList.remove( dirtyMarker );
dirtyMarker.destroy();
if ( dirtyMarker != null ) {
dirtyMarker.destroy();
}
}
}
allMap.clear();

View File

@@ -1,9 +1,11 @@
package com.mogo.module.common.drawer;
import android.content.Context;
import android.graphics.Bitmap;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
@@ -37,7 +39,7 @@ public
*
* 云端数据绘制
*/
class SnapshotSetDataDrawer {
class SnapshotSetDataDrawer extends BaseDrawer {
private static final String TAG = "SnapshotSetDataDrawer";
@@ -110,6 +112,8 @@ class SnapshotSetDataDrawer {
continue;
}
mCloudSnapshotMarkersCaches.put( uniqueKey, marker );
} else {
marker.setIcon( fromView( inflateView( cloudRoadData, machineVision, data.curSpeed ) ) );
}
if ( marker.getObject() instanceof MogoLatLng ) {
marker.setPosition( ( ( MogoLatLng ) marker.getObject() ).lat, ( ( MogoLatLng ) marker.getObject() ).lon );
@@ -197,39 +201,41 @@ class SnapshotSetDataDrawer {
private View inflateView( CloudRoadData data, boolean machineVision, double curSpeed ) {
View rootView = LayoutInflater.from( AbsMogoApplication.getApp() ).inflate( R.layout.module_commons_layout_car, null );
SafeType safeType = getSafeType( data, curSpeed );
SafeType safeType = getSafeType( data.getDistance(), data.getSpeed(), curSpeed );
TextView tv = rootView.findViewById( R.id.module_commons_marker_car_speed );
tv.setText( safeType.getMsg() );
// 机器视觉展示速度,用户视觉展示安全类型
tv.setText( machineVision ? String.valueOf( data.getSpeed() ) : safeType.getMsg() );
ImageView iv = rootView.findViewById( R.id.module_commons_marker_car_model );
iv.setImageResource( MarkerResourceManager.getMarkerDrawableResId(
machineVision ? VisionMode.Machine : VisionMode.User,
AdasRecognizedType.valueFrom( data.getType() ),
getCarModelType()
getCarModelType(),
safeType
) );
return rootView;
}
private SafeType getSafeType( CloudRoadData data, double curSpeed ) {
if ( data == null ) {
return SafeType.Normal;
}
if ( data.getDistance() < 0.5 ) {
return SafeType.DistanceDangerous;
}
if ( data.getSpeed() > curSpeed * 1.5 ) {
return SafeType.SpeedDangerous;
}
if ( data.getDistance() < 1 ) {
return SafeType.DistanceDangerous;
}
if ( data.getSpeed() > curSpeed * 1.1 ) {
return SafeType.DistanceWarm;
}
return SafeType.Normal;
private Bitmap fromView( View view ) {
view.setDrawingCacheEnabled( true );
processChildView( view );
view.destroyDrawingCache();
view.measure( View.MeasureSpec.makeMeasureSpec( 0, View.MeasureSpec.UNSPECIFIED ), View.MeasureSpec.makeMeasureSpec( 0, View.MeasureSpec.UNSPECIFIED ) );
view.layout( 0, 0, view.getMeasuredWidth(), view.getMeasuredHeight() );
Bitmap bitmap = null;
return ( bitmap = view.getDrawingCache() ) != null ? bitmap.copy( Bitmap.Config.ARGB_8888, false ) : null;
}
private CarModelType getCarModelType() {
// 根据车道、行驶方向等计算出选用哪个车模图片
return CarModelType.Other;
private void processChildView( View view ) {
if ( !( view instanceof ViewGroup ) ) {
if ( view instanceof TextView ) {
( ( TextView ) view ).setHorizontallyScrolling( false );
}
} else {
for ( int var1 = 0; var1 < ( ( ViewGroup ) view ).getChildCount(); ++var1 ) {
processChildView( ( ( ViewGroup ) view ).getChildAt( var1 ) );
}
}
}
}

View File

@@ -4,7 +4,9 @@ import com.mogo.commons.AbsMogoApplication;
import com.mogo.module.common.R;
import com.mogo.module.common.constants.AdasRecognizedType;
import com.mogo.module.common.constants.CarModelType;
import com.mogo.module.common.constants.SafeType;
import com.mogo.module.common.constants.VisionMode;
import com.mogo.utils.logger.Logger;
public
/**
@@ -15,6 +17,8 @@ public
*/
class MarkerResourceManager {
private static final String TAG = "MarkerResourceManager";
/**
* @param mode
* @param adasRecognizedType
@@ -23,7 +27,8 @@ class MarkerResourceManager {
*/
public static int getMarkerDrawableResId( VisionMode mode,
AdasRecognizedType adasRecognizedType,
CarModelType type ) {
CarModelType type,
SafeType safeType ) {
if ( mode == null ) {
mode = VisionMode.User;
}
@@ -34,20 +39,31 @@ class MarkerResourceManager {
type = CarModelType.Other;
}
if ( mode == VisionMode.Machine ) {
return R.drawable.module_common_online_car_vr_machine_middle;
if ( safeType == null ) {
safeType = SafeType.Normal;
}
StringBuilder builder = new StringBuilder();
builder.append( "module_commons" )
.append( "_" ).append( mode.getRes() )
.append( "_" ).append( adasRecognizedType.getRes() )
.append( "_" ).append( type.getRes() );
.append( "_" ).append( type.getRes() )
.append( "_" ).append( safeType.getRes() );
Logger.d( TAG, "res name = %s", builder.toString() );
int id = AbsMogoApplication.getApp().getResources().getIdentifier(
builder.toString(),
"drawable",
AbsMogoApplication.getApp().getPackageName() );
return id == 0 ? R.drawable.module_commons_user_car_other : id;
if ( id == 0 ) {
if ( mode == VisionMode.User ) {
return R.drawable.module_commons_user_car_other_normal;
} else {
return R.drawable.module_commons_machine_car_other_normal;
}
}
return id;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View File

@@ -50,6 +50,8 @@ class VrModeController {
return sInstance;
}
private boolean mIsBinding = false;
public void onVrModeChanged( boolean isVrMode ) {
if ( isVrMode ) {
bindVrModeService();
@@ -59,6 +61,10 @@ class VrModeController {
}
private void bindVrModeService() {
if ( mIsBinding ) {
return;
}
mIsBinding = true;
Intent intent = new Intent();
intent.setComponent( new ComponentName( "com.mogo.launcher.f", "com.mogo.module.machine.vision.MachineVisionMapService" ) );
AbsMogoApplication.getApp().bindService( intent, mServiceConnection = new ServiceConnection() {
@@ -85,6 +91,7 @@ class VrModeController {
}
private void unbindVrModeService() {
mIsBinding = false;
if ( mServiceConnection != null ) {
try {
AbsMogoApplication.getApp().unbindService( mServiceConnection );

View File

@@ -13,9 +13,23 @@ public
*/
class LocationResult {
/**
* sn
*/
public String sn;
/**
* 最后一个定位点的莫顿码
*/
public long mortonCode;
/**
* 最后一个定位点
*/
public CloudLocationInfo lastCoordinate;
/**
* 1s 内的连续定位点
*/
public List< CloudLocationInfo > coordinates;
}

View File

@@ -13,6 +13,13 @@ public
*/
class OnePerSecondSendContent {
/**
* 自车定位点
*/
public LocationResult self;
/**
* adas 识别物体1s 识别到的最后帧
*/
public List< ADASRecognizedResult > adas;
}

View File

@@ -164,6 +164,7 @@ class MachineVisionMapService extends Service {
mMapView.setLayoutParams(mMapView.getLayoutParams());
mMachineVisionMapViewManager.exchangeSizeAndPosition(width, height, x, y);
Logger.d(TAG, "zoom out map view");
});
}

View File

@@ -56,7 +56,6 @@ class MachineVisionMapView extends MogoBaseMapView {
onCreate( null );
postDelayed( ()->{
getMap().getUIController().showMyLocation( true );
getMap().getUIController().setAnchorScale( 1, 2.5f );
}, 1000 );
}

View File

@@ -11,12 +11,36 @@ public
*/
class ADASRecognizedListResult {
/**
* 识别物体类型
*/
public int type;
/**
* 识别物体唯一标识
*/
public String uuid;
/**
* 方向
*/
public double heading;
/**
* 速度
*/
public double speed;
/**
* x 轴距离
*/
public double distanceX;
/**
* y 轴距离
*/
public double distanceY;
/**
* 同一个uuid 1s内所对应的连续坐标
*/
public List< LatLon > latLonList;
public static class LatLon {

View File

@@ -9,17 +9,64 @@ public
*/
class ADASRecognizedResult {
/**
* 识别物体类型
*/
public int type;
/**
* 识别物体唯一标识
*/
public String uuid;
/**
* 红绿灯颜色
*/
public String color;
public String cardId;
/**
*
*/
public String carId;
/**
* 识别物体的纬度
*/
public double lat;
/**
* 识别物体的经度
*/
public double lon;
/**
* 朝向
*/
public double heading;
/**
* 系统时间
*/
public long systemTime;
/**
* 定位卫星时间
*/
public long satelliteTime;
/**
* 海拔
*/
public double alt;
/**
* 速度
*/
public double speed;
/**
* 莫顿码
*/
public long mortonCode;
}

View File

@@ -9,7 +9,6 @@ import com.zhidao.support.adas.high.bean.WarnMessageInfo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -74,7 +73,7 @@ class AdasObjectUtils {
result.alt = rectBean.getAlt();
result.color = rectBean.getColor();
result.speed = rectBean.getSpeed();
result.cardId = rectBean.getCarId();
result.carId = rectBean.getCarId();
result.mortonCode = MortonCode.wrapEncodeMorton( result.lon, result.lat );
return result;
}