改进后的显示照片(可以剪切,上传圆形的图片)

@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		if (requestCode == Photo.RESULT_IMAGE && data != null) {
			Cursor c = this.getContentResolver().query(data.getData(), null,
					null, null, null);
			c.moveToFirst();
			String imagePath = c.getString(c.getColumnIndex("_data"));
			c.close();
			File file = new File(imagePath);
			Uri originalUri = Uri.fromFile(file);
			ClipImage.startPhotoZoom(originalUri, REQUEST_CODE_CLIP,MainActivity.this);
		} else if (requestCode == Photo.RESULT_CAMERA) {
			File file = new File(Photo.TEMP_IMAGE_PATH);
			Uri uri_tack = Uri.fromFile(file);
			ClipImage.startPhotoZoom(uri_tack, REQUEST_CODE_CLIP,MainActivity.this);
		}else if(requestCode==REQUEST_CODE_CLIP){
			Bitmap photo = null;
			if (photo == null) {
				Bundle bundle = data.getExtras();
				if (bundle != null) {
					photo = (Bitmap) bundle.get("data");
				}
			}
			if (photo != null) {
				image.setImageBitmap(toRoundBitmap.toRoundBitmap(photo));
			}
		}
	}


剪切的工具类

public static void startPhotoZoom(Uri uri, int witch,Context context) {
		Intent intent = new Intent("com.android.camera.action.CROP");
		intent.setDataAndType(uri, "image/*");
		// 下面这个crop=true是设置在开启的Intent中设置显示的VIEW可裁剪
		intent.putExtra("crop", "true");
		// aspectX aspectY 是宽高的比例
		intent.putExtra("aspectX", 1);
		intent.putExtra("aspectY", 1);
		// outputX outputY 是裁剪图片宽高
		intent.putExtra("outputX", 300);
		intent.putExtra("outputY", 300);
		// 系统的裁剪图片默认对图片进行人脸识别,当识别到有人脸时,
		// 会按aspectX和aspectY为1来处理,如果想设置成自定义的裁剪比例,
		// 需要设置noFaceDetection为true。
		intent.putExtra("noFaceDetection", true);
		intent.putExtra("return-data", true);
		Activity a=(Activity)context;
		a.startActivityForResult(intent, witch);
	}

显示圆形图片的工具类

public class ToRoundBitmap {

	private static ToRoundBitmap toRoundBitmap;

	private ToRoundBitmap(Context context) {
	}

	public static ToRoundBitmap getInstance(Context context) {
		if (toRoundBitmap == null) {
			toRoundBitmap = new ToRoundBitmap(context);
		}

		return toRoundBitmap;
	}

	public Bitmap toRoundBitmap(Bitmap bitmap) {
		int width = bitmap.getWidth();
		int height = bitmap.getHeight();
		float roundPx;
		float left, top, right, bottom, dst_left, dst_top, dst_right, dst_bottom;
		if (width <= height) {
			roundPx = width / 2;

			left = 0;
			top = 0;
			right = width;
			bottom = width;

			height = width;

			dst_left = 0;
			dst_top = 0;
			dst_right = width;
			dst_bottom = width;
		} else {
			roundPx = height / 2;

			float clip = (width - height) / 2;

			left = clip;
			right = width - clip;
			top = 0;
			bottom = height;
			width = height;

			dst_left = 0;
			dst_top = 0;
			dst_right = height;
			dst_bottom = height;
		}

		Bitmap output = Bitmap.createBitmap(width, height, Config.ARGB_8888);
		Canvas canvas = new Canvas(output);

		final Paint paint = new Paint();
		final Rect src = new Rect((int) left, (int) top, (int) right,
				(int) bottom);
		final Rect dst = new Rect((int) dst_left, (int) dst_top,
				(int) dst_right, (int) dst_bottom);
		final RectF rectF = new RectF(dst);

		paint.setAntiAlias(true);// 设置画笔无锯齿

		canvas.drawARGB(0, 0, 0, 0); // 填充整个Canvas

		// 以下有两种方法画圆,drawRounRect和drawCircle
		canvas.drawRoundRect(rectF, roundPx, roundPx, paint);// 画圆角矩形,第一个参数为图形显示区域,第二个参数和第三个参数分别是水平圆角半径和垂直圆角半径。
		// canvas.drawCircle(roundPx, roundPx, roundPx, paint);

		paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));// 设置两张图片相交时的模式,参考http://trylovecatch.iteye.com/blog/1189452

		canvas.drawBitmap(bitmap, src, dst, paint);// 以Mode.SRC_IN模式合并bitmap和已经draw了的Circle

		return output;
	}
}



航拍图像多类别实例分割数据集 一、基础信息 • 数据集名称:航拍图像多类别实例分割数据集 • 图片数量: 训练集:1283张图片 验证集:416张图片 总计:1699张航拍图片 • 训练集:1283张图片 • 验证集:416张图片 • 总计:1699张航拍图片 • 分类类别: 桥梁(Bridge) 田径场(GroundTrackField) 港口(Harbor) 直升机(Helicopter) 大型车辆(LargeVehicle) 环岛(Roundabout) 小型车辆(SmallVehicle) 足球场(Soccerballfield) 游泳池(Swimmingpool) 棒球场(baseballdiamond) 篮球场(basketballcourt) 飞机(plane) 船只(ship) 储罐(storagetank) 网球场(tennis_court) • 桥梁(Bridge) • 田径场(GroundTrackField) • 港口(Harbor) • 直升机(Helicopter) • 大型车辆(LargeVehicle) • 环岛(Roundabout) • 小型车辆(SmallVehicle) • 足球场(Soccerballfield) • 游泳池(Swimmingpool) • 棒球场(baseballdiamond) • 篮球场(basketballcourt) • 飞机(plane) • 船只(ship) • 储罐(storagetank) • 网球场(tennis_court) • 标注格式:YOLO格式,包含实例分割的多边形坐标,适用于实例分割任务。 • 数据格式:航拍图像数据。 二、适用场景 • 航拍图像分析系统开发:数据集支持实例分割任务,帮助构建能够自动识别和分割航拍图像中各种物体的AI模型,用于地理信息系统、环境监测等。 • 城市
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值