머리를 자르고 싶습니다.
개시하다
넷플릭스에서 페르시아 애니메이션을 봤어요.
대단해.
안경을 쓰면'캬'이 된다.
이거 카메라 애플리케이션으로 설치하면 페르소나를 사용할 수 있잖아.
이런 녀석
해놓은 물건
드럼을 잘라 보았다.
다른 사람의 참고가 될 수 있다면 기쁘기 때문에github도 줬어요.
Kaltu
응용 프로그램의 대략적인 동작
드럼을 잘라 보았다.
다른 사람의 참고가 될 수 있다면 기쁘기 때문에github도 줬어요.
Kaltu
응용 프로그램의 대략적인 동작
이미지 자르기 제작
먼저 자신의 이미지를 촬영해 가공하는 곳이다.
눈 부분만 빼면 OK.
대략적인 설명
camera2의 샘플과 각종 사이트를 참고하여 카메라 미리보기를 표시합니다.
얼굴을 찍기 위해 전치카메라를 지정했다.
그림의 저장은 이런 느낌이다.
CreateKaltuActivity
Log.d(TAG, "onImageAvailable");
Matrix matrix = new Matrix();
matrix.preScale(0.3f, -0.3f);
final Image image = imageReader.acquireLatestImage();
ByteBuffer buffer = image.getPlanes()[0].getBuffer();
byte[] buff = new byte[buffer.remaining()];
buffer.get(buff);
Bitmap bitmap = BitmapFactory.decodeByteArray(buff, 0, buff.length);
image.close();
mCorrectRotateBitmap = Bitmap.createBitmap(bitmap, 0,0, bitmap.getWidth(), bitmap.getHeight(), matrix, false);
Frame frame = new Frame.Builder()
.setBitmap(mCorrectRotateBitmap)
.build();
SparseArray detectedFaces = mFaceDetector.detect(frame);
if (detectedFaces != null && detectedFaces.size() > 0){
float maxSize = 0;
int idx = 0;
for (int i = 0 ; i < detectedFaces.size(); i++){
Face face = (Face)detectedFaces.valueAt(i);
if (maxSize < (face.getWidth() * face.getHeight())){
maxSize = (face.getWidth() * face.getHeight());
idx = i;
}
}
Face face = (Face)detectedFaces.valueAt(idx);
// 目の位置が満足に取れないので顔の高さからざっくり計算する。
int width = mCorrectRotateBitmap.getWidth();
int height = (int)Math.floor(face.getHeight() / 4.0f);
int left = 0;
int top = (int)Math.floor(face.getPosition().y) + (int)Math.floor(height * 1.7f);
if ((height + top ) > mCorrectRotateBitmap.getHeight()){
height = mCorrectRotateBitmap.getHeight() - top;
}
Bitmap kaltuBitmap = Bitmap.createBitmap(mCorrectRotateBitmap, left, top, width, height);
try{
File file = new File(activity.getFilesDir(), "Kaltu.png");
FileOutputStream outStream = new FileOutputStream(file);
kaltuBitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
} catch (IOException e ){
Toast.makeText(activity, "Save bitmap failure", Toast.LENGTH_SHORT).show();
}
kaltuBitmap.recycle();
kaltuBitmap = null;
Message msgShowImage = Message.obtain();
msgShowImage.what = HDL_SHOW_KALTU;
mHandler.sendMessage(msgShowImage);
Message msgHideImage = Message.obtain();
msgHideImage.what = HDL_HIDE_KALTU;
mHandler.sendMessageDelayed(msgHideImage, 5000);
} else {
Toast.makeText(activity, "face not exists", Toast.LENGTH_SHORT).show();
}
bitmap.recycle();
bitmap = null;
평론에서 말한 바와 같이 눈의 위치 계산이 그다지 순조롭지 못하다얼굴 인식의 크기를 겨우 계산해 내다.
따라서 눈 위치가 좋지 않은 사람은 윗눈과 아랫눈의 사용에 신경을 써야 한다.
타협점
참고 자료
카메라 디스플레이에서 자르기 가능
화면으로 머리를 뽑아 자르다.
칼의 특징
대략적인 설명
이것은 거의 자르기 이미지 제작에서 이미지 제작을 뺀 처리이다.
일본어로는 좀 이상하지만 알아주셨으면 하는 생각이 듭니다.
카메라 지정 후면.
안 쓰는 것도 있으니 그림만 읽어도 돌려써야 한다.
EnjoyKaltuActivity
try{
File file = new File(activity.getFilesDir(), "Kaltu.png");
FileInputStream fis = new FileInputStream(file);
mKaltuBitmap = BitmapFactory.decodeStream(fis);
} catch(FileNotFoundException e){
Toast.makeText(activity, "Kaltu Not Found", Toast.LENGTH_SHORT).show();
this.finish();
}
돌아보다
놀다 보니까 고양이랑 휴지 방영하면서 자르더라고요.
심심하고 즐겁다.
Reference
이 문제에 관하여(머리를 자르고 싶습니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/miyatama/items/990580b051b6409e12da
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
Reference
이 문제에 관하여(머리를 자르고 싶습니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/miyatama/items/990580b051b6409e12da텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)