Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

android - Image quality is poor using custom camera

I am using custom camera and working fine but the issue is image is saving with very low (poor) quality. To overcome with it , i have tried all suggestions and implementations. Like ,

parameters.setJpegQuality(100);
parameters.setPictureFormat(ImageFormat.JPEG);

this is not working. After that i have used

List<Size> sizes = cameraParams.getSupportedPictureSizes();
Camera.Size size = sizes.get(0);
for(int i=0;i<sizes.size();i++)
{
 if(sizes.get(i).width > size.width)
 size = sizes.get(i);
}
cameraParams.setPictureSize(mPictureSize.width, mPictureSize.height);

This is also not working. Its saving with poor quality still.

Note : Camera preview is showing proper with good quality but the issue is when saving captured image to sdcard folder.

Advanced help would be appreciated!!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Finally my issue solved.

Here I was setting parameters for camera preview before i was capturing the image

 public void takePicture() {
    mCamera.takePicture(new ShutterCallback() {
        @Override
        public void onShutter() {

        }
    }, new PictureCallback() {
        @Override
        public void onPictureTaken(byte[] data, Camera camera) {

        }
    }, new PictureCallback() {
        @Override
        public void onPictureTaken(final byte[] data, Camera camera) {

            data1 = data;
            if (mCamera != null) {
                mCamera.stopPreview();
            }
        }
    });
}

So before i called this function in my fragment i have set parameters before this method.

mPreview.setParams(params);// This was the mistake what i have done !
mPreview.takePicture();

finally solved after removing mPreview.setParams(params);


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...