mitchtabian / TabianCustomCamera

Custom camera for android using camera2 api (DEPRECATED)
152 stars 66 forks source link

the preview you see in the room before the shot is deformed, after shot the image is instead well proportioned. #13

Closed Gianluca19 closed 4 years ago

Gianluca19 commented 5 years ago

the preview you see in the dispaly before shooting is deformed compared to reality. after shot the image is instead well proportioned.

Screenshot before shot Screenshot_2019-04-04-23-59-51

Screenshot after shot Screenshot_2019-04-05-00-00-02

Phone tets results

04-04 23:46:34.094 3693-3693/codingwithmitch.com.phonetest W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable

 OS Version: 3.10.49-1120295(G530FZXXS1BQC2)
 OS API Level: 21
 Device: grandprimelte
 Model (and Product): SM-G530FZ (grandprimeltexx)

 Display Width: 540
 Display Height: 960
 Aspect Ratio: 1.7777778
Gianluca19 commented 5 years ago

Hi Mitch, can you help me?

Gianluca19 commented 5 years ago

Hi Mitch, can you help me?

mitchtabian commented 5 years ago

Hey, So it's only distorted when the app first starts? After an initial image is taken, everything is fine?

Gianluca19 commented 5 years ago

yes, before taking the picture, what I see is distorted. after the shot I see correctly.
ps then there are other errors (if I select pen even if I draw with the finger you don't see anything. if I select stikers and then a smile, then it doesn't move if I drag it and resize it ... but I'll talk about this later)

mitchtabian commented 5 years ago

Unfortunately I'm unable to reproduce on the devices I have available. You'll have to look into it yourself.

But during the investigations I did find some other bugs (the ones you mentioned about the pen drawing).

Something must have changed since I made the course. I will look into it.

mitchtabian commented 5 years ago

Looks like it wasn't a bug. There was just something commented out in the onTouch method of Camera2Fragment.

    @SuppressLint("ClickableViewAccessibility")
    @Override
    public boolean onTouch(View view, MotionEvent motionEvent) {

        switch (motionEvent.getAction()) {

            case MotionEvent.ACTION_DOWN:{
                startX = motionEvent.getX();
                startY = motionEvent.getY();
                break;
            }

            case MotionEvent.ACTION_UP:{
                float endX = motionEvent.getX();
                float endY = motionEvent.getY();
                if (isAClick(startX, endX, startY, endY)) {
                    if(view.getId() == R.id.texture && view.getId() != R.id.stillshot){
                        Log.d(TAG, "onTouch: MANUAL FOCUS.");
                        startManualFocus(view, motionEvent);
                    }
                }
                break;
            }

            case MotionEvent.ACTION_MOVE:{
                break;
            }
        }

//        if(mIsImageAvailable){
//            Log.d(TAG, "onTouch: sending touch event to DrawableImageView");
//            return mStillshotImageView.touchEvent(motionEvent);
//        }
//        else{
//            Log.d(TAG, "onTouch: ZOOM.");
//            return mTextureView.onTouch(motionEvent);
//        }

        return true;
    }

Should be

    @SuppressLint("ClickableViewAccessibility")
    @Override
    public boolean onTouch(View view, MotionEvent motionEvent) {

        switch (motionEvent.getAction()) {

            case MotionEvent.ACTION_DOWN:{
                startX = motionEvent.getX();
                startY = motionEvent.getY();
                break;
            }

            case MotionEvent.ACTION_UP:{
                float endX = motionEvent.getX();
                float endY = motionEvent.getY();
                if (isAClick(startX, endX, startY, endY)) {
                    if(view.getId() == R.id.texture && view.getId() != R.id.stillshot){
                        Log.d(TAG, "onTouch: MANUAL FOCUS.");
                        startManualFocus(view, motionEvent);
                    }
                }
                break;
            }

            case MotionEvent.ACTION_MOVE:{
                break;
            }
        }

        if(mIsImageAvailable){
            Log.d(TAG, "onTouch: sending touch event to DrawableImageView");
            return mStillshotImageView.touchEvent(motionEvent);
        }
        else{
            Log.d(TAG, "onTouch: ZOOM.");
            return mTextureView.onTouch(motionEvent);
        }

//        return true;
    }