머리를 자르고 싶습니다.

개시하다


넷플릭스에서 페르시아 애니메이션을 봤어요.
대단해.
안경을 쓰면'캬'이 된다.
이거 카메라 애플리케이션으로 설치하면 페르소나를 사용할 수 있잖아.

이런 녀석

해놓은 물건


드럼을 잘라 보았다.

다른 사람의 참고가 될 수 있다면 기쁘기 때문에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;
    
    평론에서 말한 바와 같이 눈의 위치 계산이 그다지 순조롭지 못하다
    얼굴 인식의 크기를 겨우 계산해 내다.
    따라서 눈 위치가 좋지 않은 사람은 윗눈과 아랫눈의 사용에 신경을 써야 한다.

    타협점

  • 눈의 위치가 떨어지기 때문에 얼굴의 크기에 따라 대략적으로 계산
  • 참고 자료

  • FaceDetector
  • Android의 Camera2 API 샘플
  • Saving Files
  • 카메라 디스플레이에서 자르기 가능


    화면으로 머리를 뽑아 자르다.
    칼의 특징
  • 할인
  • 가로줄이 얇은흰색은은은근히널려있는→궁금하면
  • 나올 때의 효과→관심 있으면 하세요.
  • 나오는 시간은 2초
  • 문자로 재단
  • 대략적인 설명


    이것은 거의 자르기 이미지 제작에서 이미지 제작을 뺀 처리이다.
    일본어로는 좀 이상하지만 알아주셨으면 하는 생각이 듭니다.
    카메라 지정 후면.
    안 쓰는 것도 있으니 그림만 읽어도 돌려써야 한다.
    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();
    }
    

    돌아보다


    놀다 보니까 고양이랑 휴지 방영하면서 자르더라고요.
    심심하고 즐겁다.

    좋은 웹페이지 즐겨찾기