gpt4 book ai didi

android - CWAC 相机 - 覆盖 saveImage()

转载 作者:行者123 更新时间:2023-11-29 01:50:50 26 4
gpt4 key购买 nike

我正在尝试使用我自己的 CWAC Camera 自定义实现.我试图在我自己的 SimpleCameraHost 扩展上覆盖 saveImage 函数。这是我的代码:

You are welcome to override saveImage(byte[]) and do something else with the byte[], such as send it over the Internet. saveImage(byte[]) is called on a background thread, so you do not have to do your own asynchronous work.

@Override
public void saveImage(byte[] byteArray) {
Intent myIntent = new Intent();
retData.putExtra("data", byteArray);
getActivity().setResult(Activity.RESULT_OK, myIntent);
getActivity().finish();
}

我正在三星 galaxy S3 上测试它,它运行良好,但是当我尝试使用前置摄像头时,我的应用程序卡住并崩溃。我没有对 ActivityResult 执行任何操作,因此它源自 CameraFragment。不知道哪里出了问题,因为文档说它已经用 S3 测试过了。

编辑#2:

@Override
public Size getPictureSize(Parameters parameters) {

//return CameraUtils.getLargestPictureSize(parameters);
// TODO Auto-generated method stub
List<Camera.Size> list = parameters.getSupportedPictureSizes();
int targetWidth = 1280;
int width;
Camera.Size optimalSize= null;
for (Camera.Size size : list) {
width = size.width;
if (width==targetWidth) {
optimalSize = size;
return optimalSize;
} else if (width<targetWidth){
optimalSize = size;
return optimalSize;
} else if (width>targetWidth) {
optimalSize = size;
}
}

return optimalSize;

}

好的,所以我的代码绝对适用于将其传递给后置摄像头。当我尝试前置摄像头时,我仍然会崩溃。如果这是 Binder 错误,我不会得到 !!!失败的 BINDER 交易 !!!

堆栈跟踪:

08-12 17:36:40.559: E/YYYY(1295): Height: 960 Width: 1280
08-12 17:36:40.969: D/DeviceProfile(1295): m0xx
08-12 17:36:40.969: I/CWAC-Camera(1295): begin rotateForRealz()
08-12 17:36:40.994: D/dalvikvm(1295): GC_FOR_ALLOC freed 1937K, 8% free 40478K/43911K, paused 26ms, total 26ms
08-12 17:36:40.994: D/AbsListView(1295): [unregisterDoubleTapMotionListener]
08-12 17:36:41.004: I/dalvikvm-heap(1295): Grow heap (frag case) to 44.943MB for 4915216-byte allocation
08-12 17:36:41.039: D/dalvikvm(1295): GC_FOR_ALLOC freed 5K, 8% free 45273K/48775K, paused 34ms, total 34ms
08-12 17:36:41.059: I/MotionRecognitionManager(1295): .unregisterListener : / listener count = 0->0, listener=android.widget.AbsListView$4@436bd2e8
08-12 17:36:41.074: D/dalvikvm(1295): GC_CONCURRENT freed 21K, 8% free 45253K/48775K, paused 12ms+3ms, total 35ms
08-12 17:36:41.104: D/dalvikvm(1295): WAIT_FOR_CONCURRENT_GC blocked 0ms
08-12 17:36:41.129: D/dalvikvm(1295): GC_EXPLICIT freed <1K, 8% free 45252K/48775K, paused 2ms+3ms, total 26ms
08-12 17:36:41.149: D/dalvikvm(1295): GC_FOR_ALLOC freed 1K, 8% free 45256K/48775K, paused 15ms, total 15ms
08-12 17:36:41.154: I/dalvikvm-heap(1295): Grow heap (frag case) to 49.608MB for 4915216-byte allocation
08-12 17:36:41.184: D/dalvikvm(1295): GC_CONCURRENT freed 277K, 8% free 49778K/53639K, paused 11ms+4ms, total 29ms
08-12 17:36:41.184: D/dalvikvm(1295): WAIT_FOR_CONCURRENT_GC blocked 17ms
08-12 17:36:41.329: I/CWAC-Camera(1295): end rotateForRealz()
08-12 17:36:41.529: D/dalvikvm(1295): WAIT_FOR_CONCURRENT_GC blocked 0ms
08-12 17:36:41.559: D/dalvikvm(1295): GC_EXPLICIT freed 10806K, 24% free 40787K/53639K, paused 2ms+4ms, total 29ms
08-12 17:36:41.584: D/CameraView(1295): stopping preview
08-12 17:36:41.719: D/CameraView(1295): releasing camera
08-12 17:36:41.864: D/dalvikvm(3251): WAIT_FOR_CONCURRENT_GC blocked 0ms
08-12 17:36:41.899: D/dalvikvm(3268): WAIT_FOR_CONCURRENT_GC blocked 0ms
08-12 17:36:41.939: D/dalvikvm(3268): Trying to load lib /data/data/com.myapp.sample/lib/myappScore.so 0x429c6cf8
08-12 17:36:41.939: D/dalvikvm(3268): Added shared lib /data/data/com.myapp.sample/lib/myappScore.so 0x429c6cf8
08-12 17:36:41.939: D/dalvikvm(3268): No JNI_OnLoad found in /data/data/com.myapp.sample/lib/myappScore.so 0x429c6cf8, skipping init
08-12 17:36:41.969: I/ActionBarSherlock(3268): Registering ActionBarSherlockCompat with qualifier @com.actionbarsherlock.ActionBarSherlock$Implementation(api=7, dpi=-1)
08-12 17:36:41.969: I/ActionBarSherlock(3268): Registering ActionBarSherlockNative with qualifier @com.actionbarsherlock.ActionBarSherlock$Implementation(api=14, dpi=-1)
08-12 17:36:41.969: I/ActionBarSherlock(3268): Using implementation: ActionBarSherlockNative
08-12 17:36:41.969: D/ActionBarSherlock(3268): [<ctor>] activity: com.myapp.gui.details.ConvoDetailActivity@42a161a8, flags: 1
08-12 17:36:41.984: D/ActionBarSherlock(3268): [setContentView] layoutResId: 2130903062
08-12 17:36:42.004: D/dalvikvm(3268): GC_CONCURRENT freed 191K, 8% free 12330K/13319K, paused 13ms+12ms, total 36ms
08-12 17:36:42.019: D/dalvikvm(3268): GC_FOR_ALLOC freed 2K, 8% free 12330K/13319K, paused 10ms, total 10ms
08-12 17:36:42.019: I/dalvikvm-heap(3268): Grow heap (frag case) to 13.102MB for 353328-byte allocation
08-12 17:36:42.029: D/dalvikvm(3268): GC_FOR_ALLOC freed <1K, 8% free 12675K/13703K, paused 8ms, total 8ms
08-12 17:36:42.064: D/dalvikvm(3268): GC_FOR_ALLOC freed 5K, 8% free 12703K/13703K, paused 11ms, total 11ms
08-12 17:36:42.064: I/dalvikvm-heap(3268): Grow heap (frag case) to 15.473MB for 2457616-byte allocation
08-12 17:36:42.089: D/dalvikvm(3268): GC_CONCURRENT freed <1K, 7% free 15102K/16135K, paused 11ms+2ms, total 23ms
08-12 17:36:42.114: D/dalvikvm(3268): GC_FOR_ALLOC freed 0K, 7% free 15102K/16135K, paused 11ms, total 11ms
08-12 17:36:42.129: I/dalvikvm-heap(3268): Grow heap (frag case) to 24.847MB for 9830416-byte allocation
08-12 17:36:42.154: D/dalvikvm(3268): GC_CONCURRENT freed 0K, 5% free 24702K/25799K, paused 12ms+2ms, total 25ms
08-12 17:36:42.184: D/dalvikvm(3268): GC_FOR_ALLOC freed 2400K, 14% free 22725K/26247K, paused 12ms, total 12ms
08-12 17:36:42.234: D/dalvikvm(3268): GC_CONCURRENT freed 452K, 8% free 24310K/26247K, paused 3ms+12ms, total 26ms
08-12 17:36:42.234: D/AbsListView(3268): Get MotionRecognitionManager
08-12 17:36:42.244: D/AndroidRuntime(3268): Shutting down VM

最佳答案

I'm testing this on a samsung galaxy S3, and it works perfectly, but when I try to use the front facing camera, my application freezes up and crashes.

将来,使用 LogCat 检查崩溃时的 Java 堆栈跟踪。

在这种情况下,我的猜测是因为您试图在 Intent extra 中传递一个多 MB 的图像文件,这是行不通的。要么在拍摄图像的同一 Activity 中使用图像,要么使用其他方式传递图像(例如,通过静态数据成员小心切换)。

Don't know what could be wrong because the documentation says that it has been tested with an S3.

如果您对此表示怀疑,请尝试覆盖saveImage(),看看会发生什么。

关于android - CWAC 相机 - 覆盖 saveImage(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18196742/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com