Android Camera开发:给摄像头预览界面加个ZoomBar(附完整代码下载)

本文介绍了一种通过SeekBar组件实现相机焦距动态调节的方法。利用SeekBar的进度变化来调整相机的焦距,使得预览的画面可以放大或缩小。此外,还详细介绍了如何设置SeekBar的最大值以匹配相机的最大焦距范围。
AI助手已提取文章相关产品:

废话不说了,就是加个seekbar,拖动的话能够调节焦距,让画面变大或缩小。下面是核心程序:

一,camera的布局文件

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/BestWish"
        tools:context=".StandardCamera" />

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <FrameLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <SurfaceView
                android:id="@+id/previewSV"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />
        </FrameLayout>
        
        <LinearLayout
        android:id="@+id/zoomLayout"
        android:layout_width="wrap_content"
        android:layout_height="40dp"
        android:layout_centerInParent="true"
        android:layout_centerHorizontal="true"                
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="-"
            android:textColor="#ffffff" 
            android:textSize="30dip"/>

        <SeekBar
            android:id="@+id/seekbar_zoom"
            android:layout_width="300dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
           android:progressDrawable="@drawable/seekbar_style"
            android:thumb="@drawable/ic_launcher"
            android:thumbOffset="0dp" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
             android:text="+"
            android:textColor="#ffffff"
            android:textSize="30dip" />
    </LinearLayout>
    </RelativeLayout>

    

    <ImageButton
        android:id="@+id/photoImgBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="@drawable/photo_img_btn" />

</LinearLayout>


其中里面嵌套的LinearLayout就是那个ZoomBar,最外面我用了相对布局,发现相对布局用起来还是很好用的。为了方便以后扩展,Camera的SurfaceView用的帧布局。注意SeekBar的几个参数,其中的progressDrawable是指那个横条的形状,可以直接用个图片,也可以写个xml文件。这里用的是xml,当然用图片很简单。seekbar_style.xml文件如下:

<?xml version="1.0" encoding="UTF-8"?>   
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">   
  <item android:id="@android:id/background">  
         <shape>  
             <corners android:radius="5dip" />  
             <gradient  
                     android:startColor="#ff9d9e9d"  
                     android:centerColor="#ff5a5d5a"  
                     android:centerY="0.75"  
                     android:endColor="#ff747674"  
                     android:angle="270"  
             />  
         </shape>  
     </item>  
</layer-list>   


下面的android:thumb是滑动的那个手柄,本来我是写了一个xml文件,名字为thumb.xml如下:

<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- 按下状态 -->
    <item android:state_focused="true" android:state_pressed="true"><shape android:shape="oval">
            <gradient android:angle="0" android:centerColor="#FF00FF00" android:endColor="#000000" android:gradientRadius="8" android:startColor="#FFFF0000" android:type="radial" />

            <size android:height="20dip" android:width="20dip"></size>
        </shape></item>


</selector>

无奈啥也显示不出来,索性直接找了个粗糙的图片,见谅哈!

二,整个程序的主代码:

package yan.guoqi.camera;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;

import yan.guoqi.rectphoto.R;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Matrix;
import android.graphics.PixelFormat;
import android.hardware.Camera;
import android.hardware.Camera.AutoFocusCallback;
import android.hardware.Camera.Parameters;
import android.hardware.Camera.PictureCallback;
import android.hardware.Camera.PreviewCallback;
import android.hardware.Camera.ShutterCallback;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageButton;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;

public class StandardCamera extends Activity implements SurfaceHolder.Callback, PreviewCallback{
	private static final String tag="StandardCamera";
	private boolean isPreview = false;
	private SurfaceView mPreviewSV = null; //棰勮SurfaceView
	private SurfaceHolder mySurfaceHolder = null;
	private ImageButton mPhotoImgBtn = null;
	private Camera myCamera = null;
	private Bitmap mBitmap = null;
	private AutoFocusCallback myAutoFocusCallback = null;
	boolean flag = true;
	
	private SeekBar mZoomBar = null;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		int flag = WindowManager.LayoutParams.FLAG_FULLSCREEN;
		Window myWindow = this.getWindow();
		myWindow.setFlags(flag, flag);

		setContentView(R.layout.activity_rect_photo);

		initView();
		mySurfaceHolder = mPreviewSV.getHolder();
		mySurfaceHolder.setFormat(PixelFormat.TRANSLUCENT);
		mySurfaceHolder.addCallback(this);
		mySurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);


		myAutoFocusCallback = new AutoFocusCallback() {

			public void onAutoFocus(boolean success, Camera camera) {
				// TODO Auto-generated method stub
				if(success)
				{
					Log.i(tag, "myAutoFocusCallback: success...");


				}
				else
				{
					Log.i(tag, "myAutoFocusCallback: 澶辫触浜�?.");

				}


			}
		};
		
		//添加ZoomBar
		mZoomBar = (SeekBar)findViewById(R.id.seekbar_zoom);
		mZoomBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
			
			public void onStopTrackingTouch(SeekBar seekBar) {
				// TODO Auto-generated method stub
				
			}
			
			public void onStartTrackingTouch(SeekBar seekBar) {
				// TODO Auto-generated method stub
				
			}
			
			public void onProgressChanged(SeekBar seekBar, int progress,
					boolean fromUser) {
				// TODO Auto-generated method stub
				Parameters p = myCamera.getParameters();
				p.setZoom(progress);
				myCamera.setParameters(p);
			}
		});



	}

	public void initView(){
		mPreviewSV = (SurfaceView)findViewById(R.id.previewSV);
		WindowManager wm = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
		Display display = wm.getDefaultDisplay();
        LayoutParams lpSV = mPreviewSV.getLayoutParams();
        lpSV.width = display.getWidth();
        lpSV.height = (int) ((float)display.getHeight()*0.75);
        mPreviewSV.setLayoutParams(lpSV);


			mPhotoImgBtn = (ImageButton)findViewById(R.id.photoImgBtn);
		LayoutParams lp = mPhotoImgBtn.getLayoutParams();
		lp.width = 240;
		lp.height = 240;		
		mPhotoImgBtn.setLayoutParams(lp);				
		mPhotoImgBtn.setOnClickListener(new PhotoOnClickListener());
		mPhotoImgBtn.setOnTouchListener(new MyOnTouchListener());
	}

	public void surfaceChanged(SurfaceHolder holder, int format, int width,int height) 
	{
		// TODO Auto-generated method stub		
		Log.i(tag, "SurfaceHolder.Callback:surfaceChanged!");
		initCamera();

	}


	public void surfaceCreated(SurfaceHolder holder) 
	{
		// TODO Auto-generated method stub		
		myCamera = Camera.open();
		try {
			myCamera.setPreviewDisplay(mySurfaceHolder);
			Log.i(tag, "SurfaceHolder.Callback: surfaceCreated!");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			if(null != myCamera){
				myCamera.release();
				myCamera = null;
			}
			e.printStackTrace();
		}



	}


	public void surfaceDestroyed(SurfaceHolder holder) 

	{
		// TODO Auto-generated method stub
		Log.i(tag, "SurfaceHolder.Callback锛歋urface Destroyed");
		if(null != myCamera)
		{
			myCamera.setPreviewCallback(null); 

			myCamera.stopPreview(); 
			isPreview = false; 
			myCamera.release();
			myCamera = null;     
		}

	}

	public void initCamera(){
		if(isPreview){
			myCamera.stopPreview();
		}
		if(null != myCamera){			
			Camera.Parameters myParam = myCamera.getParameters();


			myParam.setPictureFormat(PixelFormat.JPEG);//璁剧疆鎷嶇収鍚庡瓨鍌ㄧ殑鍥剧墖鏍煎紡

			
			//List<Size> pictureSizes = myParam.getSupportedPictureSizes();
						//List<Size> previewSizes = myParam.getSupportedPreviewSizes();
			//			for(int i=0; i<pictureSizes.size(); i++){
			//				Size size = pictureSizes.get(i);
			//				Log.i(tag, "initCamera:pictureSizes: width = "+size.width+"height = "+size.height);
			//			}
			//			for(int i=0; i<previewSizes.size(); i++){
			//				Size size = previewSizes.get(i);
			//				Log.i(tag, "initCamera:鎽勫儚澶存敮鎸佺殑previewSizes: width = "+size.width+"height = "+size.height);
			//
			//			}



			myParam.setPictureSize(1280, 960);  //
			myParam.setPreviewSize(960, 720);	//		
			//myParam.set("rotation", 90);  			
			myCamera.setDisplayOrientation(90);  
			List<String> focuseMode = (myParam.getSupportedFocusModes());
			for(int i=0; i<focuseMode.size(); i++){
				Log.i(tag, focuseMode.get(i));
				if(focuseMode.get(i).contains("continuous")){
					myParam.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
				}
				else{
					myParam.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);

				}
			}
			//设置mZoomBar的最大值
			mZoomBar.setMax(myParam.getMaxZoom());
			myCamera.setParameters(myParam);			
			myCamera.startPreview();
			myCamera.autoFocus(myAutoFocusCallback);
			isPreview = true;
		}
	}

	ShutterCallback myShutterCallback = new ShutterCallback() 
	{

		public void onShutter() {
			// TODO Auto-generated method stub
			Log.i(tag, "myShutterCallback:onShutter...");

		}
	};
	PictureCallback myRawCallback = new PictureCallback() 
	{

		public void onPictureTaken(byte[] data, Camera camera) {
			// TODO Auto-generated method stub
			Log.i(tag, "myRawCallback:onPictureTaken...");

		}
	};
	PictureCallback myJpegCallback = new PictureCallback() 
	{

		public void onPictureTaken(byte[] data, Camera camera) {
			// TODO Auto-generated method stub
			Log.i(tag, "myJpegCallback:onPictureTaken...");
			if(null != data){
				mBitmap = BitmapFactory.decodeByteArray(data, 0, data.length);//data鏄瓧鑺傛暟鎹紝灏嗗叾瑙f瀽鎴愪綅鍥�				myCamera.stopPreview();
				isPreview = false;
			}
			Matrix matrix = new Matrix();
			matrix.postRotate((float)90.0);
			Bitmap rotaBitmap = Bitmap.createBitmap(mBitmap, 0, 0, mBitmap.getWidth(), mBitmap.getHeight(), matrix, false);
			if(null != rotaBitmap)
			{
				saveJpeg(rotaBitmap);
			}

			myCamera.startPreview();
			isPreview = true;
		}
	};
	public class PhotoOnClickListener implements OnClickListener{

		public void onClick(View v) {
			// TODO Auto-generated method stub
			if(isPreview && myCamera!=null){
				myCamera.takePicture(myShutterCallback, null, myJpegCallback);	
			}

		}

	}

	public void saveJpeg(Bitmap bm){
		String savePath = "/mnt/sdcard/rectPhoto/";
		File folder = new File(savePath);
		if(!folder.exists()) {
			folder.mkdir();
		}
		long dataTake = System.currentTimeMillis();
		String jpegName = savePath + dataTake +".jpg";
		Log.i(tag, "saveJpeg:jpegName--" + jpegName);
		//File jpegFile = new File(jpegName);
		try {
			FileOutputStream fout = new FileOutputStream(jpegName);
			BufferedOutputStream bos = new BufferedOutputStream(fout);

			//			Bitmap newBM = bm.createScaledBitmap(bm, 600, 800, false);

			bm.compress(Bitmap.CompressFormat.JPEG, 100, bos);
			bos.flush();
			bos.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block

			e.printStackTrace();
		}
	}


	public class MyOnTouchListener implements OnTouchListener{

		public final  float[] BT_SELECTED=new float[]
				{ 2, 0, 0, 0, 2,
				0, 2, 0, 0, 2,
				0, 0, 2, 0, 2,
				0, 0, 0, 1, 0 };			    

		public final float[] BT_NOT_SELECTED=new float[]
				{ 1, 0, 0, 0, 0,
				0, 1, 0, 0, 0,
				0, 0, 1, 0, 0,
				0, 0, 0, 1, 0 };
		public boolean onTouch(View v, MotionEvent event) {
			// TODO Auto-generated method stub
			if(event.getAction() == MotionEvent.ACTION_DOWN){
				v.getBackground().setColorFilter(new ColorMatrixColorFilter(BT_SELECTED));
				v.setBackgroundDrawable(v.getBackground());
			}
			else if(event.getAction() == MotionEvent.ACTION_UP){
				v.getBackground().setColorFilter(new ColorMatrixColorFilter(BT_NOT_SELECTED));
				v.setBackgroundDrawable(v.getBackground());

			}
			return false;
		}

	}

	@Override
	public void onBackPressed()
	{
		// TODO Auto-generated method stub
		super.onBackPressed();
		StandardCamera.this.finish();
	}



	class UpdateThread implements Runnable{

		public void run() {
			// TODO Auto-generated method stub
			while(flag){
				if(myCamera!=null && isPreview)
					myCamera.autoFocus(myAutoFocusCallback); //鑷姩鑱氱劍
				myCamera.setOneShotPreviewCallback(StandardCamera.this); //onPreviewFrame閲屼細鎺ュ彈鍒版暟鎹�?			myCamera.stopPreview(); //鍋滄棰勮
				flag = false;

				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}

	}



	public void onPreviewFrame(byte[] data, Camera camera) {
		// TODO Auto-generated method stub

	}
}

需要注意的有以下几点:

1,为了让程序适用不同的手机,onCreate函数里用如下代码初始化SurfaceView的大小,避免以前写死的方法:

public void initView(){
mPreviewSV = (SurfaceView)findViewById(R.id.previewSV);
WindowManager wm = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
LayoutParams lpSV = mPreviewSV.getLayoutParams();
lpSV.width = display.getWidth();
lpSV.height = (int) ((float)display.getHeight()*0.75);
mPreviewSV.setLayoutParams(lpSV);

mPhotoImgBtn = (ImageButton)findViewById(R.id.photoImgBtn);
LayoutParams lp = mPhotoImgBtn.getLayoutParams();
lp.width = 240;
lp.height = 240;
mPhotoImgBtn.setLayoutParams(lp);
mPhotoImgBtn.setOnClickListener(new PhotoOnClickListener());
mPhotoImgBtn.setOnTouchListener(new MyOnTouchListener());
}

2,关于ZoomBar的代码片段很简短,如下:


mPhotoImgBtn = (ImageButton)findViewById(R.id.photoImgBtn);
LayoutParams lp = mPhotoImgBtn.getLayoutParams();
lp.width = 240;
lp.height = 240;
mPhotoImgBtn.setLayoutParams(lp);
mPhotoImgBtn.setOnClickListener(new PhotoOnClickListener());
mPhotoImgBtn.setOnTouchListener(new MyOnTouchListener());
}
//添加ZoomBar
mZoomBar = (SeekBar)findViewById(R.id.seekbar_zoom);
mZoomBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub

}

public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub

}

public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
// TODO Auto-generated method stub
Parameters p = myCamera.getParameters();
p.setZoom(progress);
myCamera.setParameters(p);
}
});

3,在initCamera函数里,查询camera支持的聚焦模式,如果带连续视频聚焦则使用连续视频聚焦,否则使用自动聚焦:


mPhotoImgBtn = (ImageButton)findViewById(R.id.photoImgBtn);
LayoutParams lp = mPhotoImgBtn.getLayoutParams();
lp.width = 240;
lp.height = 240;
mPhotoImgBtn.setLayoutParams(lp);
mPhotoImgBtn.setOnClickListener(new PhotoOnClickListener());
mPhotoImgBtn.setOnTouchListener(new MyOnTouchListener());
}
List<String> focuseMode = (myParam.getSupportedFocusModes());
for(int i=0; i<focuseMode.size(); i++){
Log.i(tag, focuseMode.get(i));
if(focuseMode.get(i).contains("continuous")){
myParam.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
}
else{
myParam.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
}
}

4,同样在initCamera函数里,设置ZoomBar的最大值:
//设置mZoomBar的最大值
mZoomBar.setMax(myParam.getMaxZoom());

后续将写专文分析Camera4.0的源码,并且模仿到自己的代码中!

源码下载链接:http://download.youkuaiyun.com/detail/yanzi1225627/6421779

您可能感兴趣的与本文相关内容

eekBar: drawCircleAndIconInternal, needAnimation:false, upScale: 1.0, icon: TELE, fadeIn: false, fadeOut: false, upscale: 1.0, iconText: 0.6×, pivotX: 648.0 10-24 17:27:43.080405 10559 10559 V OCAM_ZoomSeekBar: getZoomValue, IconType: TELE zoomPointMap: {ULTRA_WIDE=0.6, WIDE=1.0, DUAL=2.0, TELE=3.5, MORE=7.0} 10-24 17:27:43.080415 10559 10559 V OCAM_ZoomSeekBar: drawTextSpecialStyle, mCurrentDisplayUnitText:× 10-24 17:27:43.080429 10559 10559 D OCAM_ZoomSeekBar: keepLatestDisplayText, type:TELE, text: 3.5, isSelected:false 10-24 17:27:43.080441 10559 10559 V OCAM_ZoomSeekBar: getClickPointType, index: 0, zoomPointMap: {ULTRA_WIDE=0.6, WIDE=1.0, DUAL=2.0, TELE=3.5, MORE=7.0}, ret:1 10-24 17:27:43.080451 10559 10559 V OCAM_ZoomSeekBar: getClickPointType, index: 0, zoomPointMap: {ULTRA_WIDE=0.6, WIDE=1.0, DUAL=2.0, TELE=3.5, MORE=7.0}, ret:1 10-24 17:27:43.080460 10559 10559 V OCAM_ZoomSeekBar: getClickPointType, index: 0, zoomPointMap: {ULTRA_WIDE=0.6, WIDE=1.0, DUAL=2.0, TELE=3.5, MORE=7.0}, ret:1 10-24 17:27:43.080473 10559 10559 V OCAM_ZoomSeekBar: drawCircleAndIconInternal, needAnimation:false, upScale: 1.0, icon: MORE, fadeIn: false, fadeOut: false, upscale: 1.0, iconText: 0.6×, pivotX: 756.0 10-24 17:27:43.080480 10559 10559 V OCAM_ZoomSeekBar: getZoomValue, IconType: MORE zoomPointMap: {ULTRA_WIDE=0.6, WIDE=1.0, DUAL=2.0, TELE=3.5, MORE=7.0} 10-24 17:27:43.080489 10559 10559 V OCAM_ZoomSeekBar: drawTextSpecialStyle, mCurrentDisplayUnitText:× 10-24 17:27:43.080502 10559 10559 D OCAM_ZoomSeekBar: keepLatestDisplayText, type:MORE, text: 7, isSelected:false 10-24 17:27:43.087307 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.087445 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.087464 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.098683 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.098777 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.098794 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.109382 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.109611 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.109632 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.120569 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.120682 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.120701 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.131623 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.131795 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.131874 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.142442 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.142491 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.142506 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.144469 2676 6395 I Camera3-Status: dumpActiveComponents: component 12 (Stream 26) is active 10-24 17:27:43.144633 2676 6395 I Camera3-Status: dumpActiveComponents: component 13 (Stream 33) is active 10-24 17:27:43.144668 2676 6395 E Camera3-Device: Camera 0: waitUntilDrainedLocked: Error waiting for HAL to drain: Connection timed out (-110) 10-24 17:27:43.154529 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.154618 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.154636 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.157666 1926 28524 I resolv : res_nsend: used send_dg 0 terrno: 110 10-24 17:27:43.165001 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.165261 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.165274 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.175409 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.175529 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.175598 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.186132 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.186169 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.186176 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.197258 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.197295 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.197302 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.208141 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.208179 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.208214 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.219029 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.219051 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.219055 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.230096 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.230132 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.230144 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.240470 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.240639 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.240724 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.241226 2676 6395 D CameraTraces: Process trace saved. Use dumpsys media.camera to view. 10-24 17:27:43.242505 10559 11160 E CameraCaptureSession: Session 4: Failed to create capture session; configuration failed 10-24 17:27:43.242795 10559 11161 W om.oplus.camera: Long monitor contention with owner CameraControlThread (11160) at void android.hardware.camera2.impl.CameraDeviceImpl.waitUntilIdle()(CameraDeviceImpl.java:1799) waiters=0 in void android.hardware.camera2.impl.CameraDeviceImpl$6.run() for 5.098s 10-24 17:27:43.242929 10559 11160 E CameraUnit, ProducerImpl: onSessionConfigureFail, error result: [error code: 10002, error info: stream surface error] 10-24 17:27:43.243071 10559 11160 E OCAM_OneCameraImpl: onCameraPreviewError, error: PREVIEW_CONFIG_FAILED 10-24 17:27:43.243117 10559 11160 E OCAM_AutoLogHelper: tryCatchPreviewExceptionLog , reason: PREVIEW_CONFIG_FAILED, triggerReason: -1 10-24 17:27:43.243189 10559 11161 I Quality : MonitorInfo:com.oplus.camera,run,CameraDeviceImpl.java_299,5099 10-24 17:27:43.243249 10559 11160 E OCAM_AutoLogHelper: tryCatchPreviewExceptionLog inner, reason: PREVIEW_CONFIG_FAILED 10-24 17:27:43.243390 10559 10643 I Quality : MonitorInfo:com.oplus.camera,onDeviceError,CameraDeviceImpl.java_2286,98 10-24 17:27:43.243608 10559 11160 I CameraUnit, Camera2StateMachineImpl: setDeviceState, cameraName: rear_sat, mDeviceState: SESSION_CREATING -> SESSION_CONFIGURED_FAILED 10-24 17:27:43.243941 10559 11161 D CameraUnit, StateCallback: onConfigureFailed,android.hardware.camera2.impl.CameraCaptureSessionImpl@fc22b11 10-24 17:27:43.243999 10559 11161 E CameraUnit, ProducerImpl: onSessionConfigureFail, error result: [error code: 10002, error info: stream surface error] 10-24 17:27:43.244035 10559 11161 E OCAM_OneCameraImpl: onCameraPreviewError, error: PREVIEW_CONFIG_FAILED 10-24 17:27:43.244055 10559 11161 E OCAM_AutoLogHelper: tryCatchPreviewExceptionLog , reason: PREVIEW_CONFIG_FAILED, triggerReason: -1 10-24 17:27:43.244091 10559 11161 E OCAM_AutoLogHelper: tryCatchPreviewExceptionLog inner, reason: PREVIEW_CONFIG_FAILED 10-24 17:27:43.244145 10559 11161 I CameraUnit, Camera2StateMachineImpl: setDeviceState, cameraName: rear_sat, mDeviceState: SESSION_CONFIGURED_FAILED -> SESSION_CONFIGURED_FAILED 10-24 17:27:43.244275 10559 11161 D CameraUnit, StateCallback: onError,android.hardware.camera2.impl.CameraDeviceImpl@34dce5, cameraUnit version: 6.106.63 10-24 17:27:43.244303 10559 25616 D OCAM_FeatureConflictDecision: onDataChanged: mmkv://com.oplus.camera/com.oplus.camera_preferences?class_type=java.lang.Long#preview_exception 10-24 17:27:43.244333 10559 11161 E CameraUnit, Camera2StateMachineImpl: onError, ops, camera have some error, error code: 4 10-24 17:27:43.244362 10559 25616 D OCAM_FeatureConflictDecision: getFeatureConflictMap, getFeatureConflictMap: featureKey: preview_exception, featureValueType: class java.lang.Long, has none featureInfo! 10-24 17:27:43.244394 10559 25616 D OCAM_ZoomPresenter: onDataChanged, prefKey: preview_exception 10-24 17:27:43.244445 10559 25616 V OCAM_CameraCore: onDataChanged, dataKey: preview_exception, this: com.oplus.camera.CameraManager@6bbe82d, mActivity: com.oplus.camera.Camera@e979857 10-24 17:27:43.244681 10559 25616 E OCAM_AutoLogManager: try to catch. 10-24 17:27:43.244858 10559 25616 E OCAM_AutoLogManager: prepare capture. 10-24 17:27:43.245025 10559 25616 E OCAM_AutoLogHelper: tryCatchPreviewExceptionLog onCatch, request: Request{requestReason='PREVIEW_CONFIG_FAILED', mLux=-1, mExceptionID=268505089, mMemoryAvailable=-1.0, mRunningMemoryAvailable=-1.0, mTemperature=-1.0, mCaptureModeName='common', mTimeStamp=1761298063244'}, result: CatchResult{mResultCode='failed', mDetailInfo='Interval limit denied, checkIntervalLimit: 604800000', mRequest=null} 10-24 17:27:43.245336 10559 25616 E OCAM_AutoLogManager: try to catch. 10-24 17:27:43.245417 10559 25616 D OCAM_LogCoreManager: sendException mOlcServiceInterface: com.oplus.olc.IOplusLogCore$Stub$Proxy@d850db0 10-24 17:27:43.245700 10559 25237 E OCAM_OneCameraImpl: onSessionConfigureFail, errorCode: 10002, errorInfo: stream surface error 10-24 17:27:43.245738 10559 25237 E OCAM_PreviewProcessor: onSessionConfigureFailed 10-24 17:27:43.245794 10559 25237 I OCAM_PreviewProcessor: changePreviewState, CREATING_CAPTURE_SESSION -> INIT 10-24 17:27:43.245831 10559 25237 V OCAM_OppoCamera_TRACE: traceBeginSection, msg: PreviewProcessor.raisePreviewControlEvent 10-24 17:27:43.245955 10559 11161 E CameraUnit, ProducerImpl: onCameraError, error result: [error code: 4, error info: camera device error, at: com.oplus.ocs.camera.producer.device.Camera2StateMachineImpl$1.onError(Camera2StateMachineImpl.java:128)] 10-24 17:27:43.246148 10559 25237 V OCAM_k1_BaseMode: getPictureSize, sizeList: [4096x3072, 3840x2160, 3840x1644, 3840x1608, 3280x1856, 3264x2448, 2880x2160, 2640x1200, 2624x1968, 2580x1080, 2560x1440, 2520x1080, 2344x1080, 2304x1728, 2304x1060, 2304x1048, 2160x1080, 2136x1200, 1920x1440, 1920x1280, 1920x1080, 4096x2304, 4096x1888, 4000x1818, 4000x3000, 4000x2250, 3840x2560, 3456x3456, 3136x2352, 3072x3072, 3000x3000, 2976x2232, 2944x2208, 2560x1920, 1984x1488, 1856x1392, 2016x1512, 1728x1296, 1680x1260, 1600x1200, 480x360, 480x270, 480x218, 360x360] 10-24 17:27:43.246159 10559 11161 D CameraUnit, StatisticsManager: report, mAppId: 20009, mEventId: abnormal_display, params: {pack_name=com.oplus.camera, rear_front=rear, abnormal_preview=1, camera_id=0, enter_time=1735660858753, preview_start_time=1761298042708} 10-24 17:27:43.246210 10559 11160 E CameraUnit, Camera2StateMachineImpl: handleMessage, create capture session failed. android.hardware.camera2.CameraAccessException: CAMERA_ERROR (3): waitUntilIdle:1776: Camera 0: Error waiting to drain: Connection timed out (-110) at android.hardware.camera2.utils.ExceptionUtils.throwAsPublicException(ExceptionUtils.java:75) at android.hardware.camera2.impl.ICameraDeviceUserWrapper.waitUntilIdle(ICameraDeviceUserWrapper.java:199) at android.hardware.camera2.impl.CameraDeviceImpl.waitUntilIdle(CameraDeviceImpl.java:1798) at android.hardware.camera2.impl.CameraDeviceImpl.configureStreamsChecked(CameraDeviceImpl.java:732) at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureSessionInternal(CameraDeviceImpl.java:1053) at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureSession(CameraDeviceImpl.java:981) at com.oplus.ocs.camera.producer.device.Camera2Impl.createNewSession(Camera2Impl.java:3136) at com.oplus.ocs.camera.producer.device.Camera2StateMachineImpl$StateMachineHandler.handleMessage(Camera2StateMachineImpl.java:413) at android.os.Handler.dispatchMessage(Handler.java:115) at android.os.Looper.loopOnce(Looper.java:298) at android.os.Looper.loop(Looper.java:408) at android.os.HandlerThread.run(HandlerThread.java:85) at com.oplus.ocs.camera.common.util.CameraHandlerThread.run(CameraHandlerThread.java:36) Caused by: android.os.ServiceSpecificException: waitUntilIdle:1776: Camera 0: Error waiting to drain: Connection timed out (-110) (code 10) at android.os.Parcel.createExceptionOrNull(Parcel.java:3384) at android.os.Parcel.createException(Parcel.java:3354) at android.os.Parcel.readException(Parcel.java:3337) at android.os.Parcel.readException(Parcel.java:3279) at android.hardware.camera2.ICameraDeviceUser$Stub$Proxy.waitUntilIdle(ICameraDeviceUser.java:984) at android.hardware.camera2.impl.ICameraDeviceUserWrapper.waitUntilIdle(ICameraDeviceUserWrapper.java:197) ... 11 more 10-24 17:27:43.246318 10559 25237 V OCAM_SizeUtils: getOptimalSizeByRatio, size: 4096x2304, targetRatio: 1.7777777777777777 precise true 10-24 17:27:43.246358 10559 25237 I OCAM_SeamlessUIControl: onPreviewStateChanged, previewState : PREVIEW_STATE_INIT 10-24 17:27:43.246379 10559 11160 D CameraUnit, Camera2StateMachineImpl: closeCameraDecision这又是什么情况,在刚刚的日志上面打印的
最新发布
10-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值