|
@ -33,11 +33,12 @@ public class UVCCameraHelper { |
|
|
private int previewWidth = 640; |
|
|
private int previewWidth = 640; |
|
|
private int previewHeight = 480; |
|
|
private int previewHeight = 480; |
|
|
// 高分辨率YUV格式帧率较低
|
|
|
// 高分辨率YUV格式帧率较低
|
|
|
private static int FRAME_FORMAT_YUYV = UVCCamera.FRAME_FORMAT_YUYV; |
|
|
public static final int FRAME_FORMAT_YUYV = UVCCamera.FRAME_FORMAT_YUYV; |
|
|
// 默认使用MJPEG
|
|
|
// 默认使用MJPEG
|
|
|
private static int FRAME_FORMAT_MJPEG = UVCCamera.FRAME_FORMAT_MJPEG; |
|
|
public static final int FRAME_FORMAT_MJPEG = UVCCamera.FRAME_FORMAT_MJPEG; |
|
|
public static int MODE_BRIGHTNESS = UVCCamera.PU_BRIGHTNESS; |
|
|
public static final int MODE_BRIGHTNESS = UVCCamera.PU_BRIGHTNESS; |
|
|
public static int MODE_CONTRAST = UVCCamera.PU_CONTRAST; |
|
|
public static final int MODE_CONTRAST = UVCCamera.PU_CONTRAST; |
|
|
|
|
|
private int mFrameFormat = FRAME_FORMAT_MJPEG; |
|
|
|
|
|
|
|
|
private static UVCCameraHelper mCameraHelper; |
|
|
private static UVCCameraHelper mCameraHelper; |
|
|
// USB Manager
|
|
|
// USB Manager
|
|
@ -151,7 +152,7 @@ public class UVCCameraHelper { |
|
|
// initialize camera handler
|
|
|
// initialize camera handler
|
|
|
mCamView.setAspectRatio(previewWidth / (float)previewHeight); |
|
|
mCamView.setAspectRatio(previewWidth / (float)previewHeight); |
|
|
mCameraHandler = UVCCameraHandler.createHandler(mActivity, mCamView, 2, |
|
|
mCameraHandler = UVCCameraHandler.createHandler(mActivity, mCamView, 2, |
|
|
previewWidth, previewHeight, FRAME_FORMAT_MJPEG); |
|
|
previewWidth, previewHeight, mFrameFormat); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void updateResolution(int width, int height) { |
|
|
public void updateResolution(int width, int height) { |
|
@ -166,7 +167,7 @@ public class UVCCameraHelper { |
|
|
} |
|
|
} |
|
|
mCamView.setAspectRatio(previewWidth / (float)previewHeight); |
|
|
mCamView.setAspectRatio(previewWidth / (float)previewHeight); |
|
|
mCameraHandler = UVCCameraHandler.createHandler(mActivity,mCamView, 2, |
|
|
mCameraHandler = UVCCameraHandler.createHandler(mActivity,mCamView, 2, |
|
|
previewWidth, previewHeight, FRAME_FORMAT_MJPEG); |
|
|
previewWidth, previewHeight, mFrameFormat); |
|
|
openCamera(mCtrlBlock); |
|
|
openCamera(mCtrlBlock); |
|
|
new Thread(new Runnable() { |
|
|
new Thread(new Runnable() { |
|
|
@Override |
|
|
@Override |
|
@ -332,6 +333,13 @@ public class UVCCameraHelper { |
|
|
this.previewHeight = defaultHeight; |
|
|
this.previewHeight = defaultHeight; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setDefaultFrameFormat(int format) { |
|
|
|
|
|
if(mUSBMonitor != null) { |
|
|
|
|
|
throw new IllegalStateException("setDefaultFrameFormat should be call before initMonitor"); |
|
|
|
|
|
} |
|
|
|
|
|
this.mFrameFormat = format; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public int getPreviewWidth() { |
|
|
public int getPreviewWidth() { |
|
|
return previewWidth; |
|
|
return previewWidth; |
|
|
} |
|
|
} |
|
|