mCamera.takePicture(null,null,mPicture)不起作用

时间:2018-03-11 08:45:01

标签: java android android-camera

我按照https://developer.android.com/guide/topics/media/camera.html激活Android 4的自定义相机,但我的捕捉功能完全不起作用。以下是我的代码:

cameraf.java:

import pygame
file = 'some.mp3'
pygame.init()
pygame.mixer.init()
pygame.mixer.music.load(file)
pygame.mixer.music.play()
pygame.event.wait()

我已经在manifest中添加了权限 uses-permission android:name =" android.permission.CAMERA",uses-permission android:name =" android.permission .WRITE_EXTERNAL_STORAGE"

但是从上面的代码中它可以让我打开相机但是当我点击屏幕时它会变成错误并且无法存储图像。那么任何人都可以分享我的想法吗?

错误: enter image description here

1 个答案:

答案 0 :(得分:0)

您看到的失败可能是因为您没有设置图片大小。有些设备需要这样做。

请注意,您必须选择一种支持的尺寸,并确保图片尺寸和预览尺寸同步(即具有相同的宽高比)。

您无法设置从表面视图大小派生的预览尺寸...实际上,您不会:您的通话

df = pd.merge(datain, template, how='left')
print (df)
  SampleName ProbeName  Value     QC
0   sample 1   probe 1      5   True
1   sample 1   probe 2      4   True
2   sample 1   probe 3      3   True
3   sample 1   probe 4      2  False
4   sample 1   probe 5      1  False
5   sample 2   probe 1      1   True
6   sample 2   probe 2      4   True
7   sample 2   probe 3      3   True
8   sample 2   probe 4      2  False
9   sample 2   probe 5      1  False

s = df[df['QC']].groupby('SampleName')['Value'].sum()
df['new'] = df['SampleName'].map(s)
print (df)
  SampleName ProbeName  Value     QC  new
0   sample 1   probe 1      5   True   12
1   sample 1   probe 2      4   True   12
2   sample 1   probe 3      3   True   12
3   sample 1   probe 4      2  False   12
4   sample 1   probe 5      1  False   12
5   sample 2   probe 1      1   True    8
6   sample 2   probe 2      4   True    8
7   sample 2   probe 3      3   True    8
8   sample 2   probe 4      2  False    8
9   sample 2   probe 5      1  False    8

后面没有

print (df[df['QC']])
  SampleName ProbeName  Value    QC
0   sample 1   probe 1      5  True
1   sample 1   probe 2      4  True
2   sample 1   probe 3      3  True
5   sample 2   probe 1      1  True
6   sample 2   probe 2      4  True
7   sample 2   probe 3      3  True

print (s)
SampleName
sample 1    12
sample 2     8
Name: Value, dtype: int64