嘿家伙我正在使用以下代码从我的应用程序访问相机.该应用程序能够访问相机我还添加了一个按钮,其onclicklistener添加这行代码: -
camera.takePicture(mShutterCallback, mPictureCallbackRaw, mPictureCallbackJpeg);
Run Code Online (Sandbox Code Playgroud)
现在我不知道发生了什么,但应用程序卡住我必须强制关闭它然后我甚至无法访问本机相机应用程序.我认为它会在不释放Camera对象的情况下离开应用程序.此外,图像永远不会被保存.
代码: -
SurfaceHolder holder;
SurfaceView surface;
Camera camera;
Boolean isPreviewRunning, fromOnResume;
//Preview mpreview;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
isPreviewRunning = false;
fromOnResume = false;
// requestWindowFeature(Window.FEATURE_NO_TITLE);
surface = (SurfaceView)findViewById(R.id.surface);
holder = surface.getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
Button btn = (Button)findViewById(R.id.click);
btn.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
camera.takePicture(mShutterCallback, mPictureCallbackRaw, mPictureCallbackJpeg);
//onCreate(null);
}
});
}
@Override
public void surfaceChanged(SurfaceHolder …Run Code Online (Sandbox Code Playgroud) 正如标题所说,我想从最小化的窗口捕获图像......甚至可能吗?我使用msdn 的CaptureAnImage,它可以工作,除非窗口最小化.
我尝试过的一个解决方案是最大化它,捕获图像,然后将其恢复到原始状态.唯一的问题是动画看起来很难看,我想找个替代方案......以下是我试过的方法:
WINDOWPLACEMENT wInfo;
UINT originalPlacement;
GetWindowPlacement(hWnd, &wInfo);
originalPlacement = wInfo.showCmd;
wInfo.showCmd = SW_MAXIMIZE;
SetWindowPlacement(hWnd, &wInfo);
wInfo.showCmd = originalPlacement;
CaptureAnImage(hWnd); // Capture the image while it's maximized
SetWindowPlacement(hWnd, &wInfo);
Run Code Online (Sandbox Code Playgroud)
所以我在这里寻找其中一个解决方案:
是否有可能在图像最小化时捕获图像?
要么
是否可以最大化它,捕获它,然后将其恢复到原始状态而不显示任何类型的动画?
PS:我在搜索我的问题时找到了链接,但它在c#中,我无法在c ++中使用它...
我正在尝试使用外部Android摄像头将图像放入ImageView中,但是我收到了"失败传递结果ResultInfo"错误.这是我的代码:
单击按钮以启动相机应用程序
public void takePhoto(View v) {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
// Creating the File where the photo should go
File photoFile = null;
try {
photoFile = createImageFile();
} catch (IOException ex) {
// Error occurred while creating the File
Log.e(TAG,"something went wrong", ex);
return;
}
// Continue only if the File was successfully created
if (photoFile != null) {
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(photoFile));
startActivityForResult(takePictureIntent, REQUEST_CODE);
}
}
}
Run Code Online (Sandbox Code Playgroud)
命名和创建临时.文件:
String mCurrentPhotoPath;
private File createImageFile() …Run Code Online (Sandbox Code Playgroud) 我目前正在寻找一个简单的应用程序.
我已经看过其他应用程序和堆栈溢出问题似乎没有帮助.
我想让应用程序使用build i网络摄像头拍摄图像并在一个摇摆gui中显示..然后拍摄另一张照片说2秒后..检查它是否与第一张相同并丢弃它,如果它的其他展示下?
我有以下问题:
是否可以轻松地做到这一点,而不是使用大量的libarys?
那里有任何示例/简单代码吗?