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

Categories

0 votes
1.4k 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 Answer

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);


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...