嘿家伙我正在使用以下代码从我的应用程序访问相机.该应用程序能够访问相机我还添加了一个按钮,其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) 我在以下代码行中收到错误:
FileInputStream is = new FileInputStream("/sdcard/DCIM/ROBIN.jpg");
Run Code Online (Sandbox Code Playgroud)
错误是:
java.io.FileNotFoundException: /sdcard/DCIM/ROBIN.jpg (No such file or directory)
Run Code Online (Sandbox Code Playgroud)
但图像存在于目录中
我的USB连接仅限充电
我正在尝试将UIImagePickerController中的相机闪光模式设置为关闭,但我不明白参考页面.这是我的代码:
- (void)getMediaFromSource:(UIImagePickerControllerSourceType)sourceType {
NSArray *mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:sourceType];
if ([UIImagePickerController isSourceTypeAvailable:
sourceType] && [mediaTypes count] > 0) {
NSArray *mediaTypes = [UIImagePickerController
availableMediaTypesForSourceType:sourceType];
mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeImage, nil];
UIImagePickerController *picker =
[[UIImagePickerController alloc] init];
UIImagePickerControllerCameraDevice *device;
picker.mediaTypes = mediaTypes;
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = sourceType;
[self presentModalViewController:picker animated:YES];
[picker release];
}}
Run Code Online (Sandbox Code Playgroud)
我已经尝试设置picker.cameraDevice = UIImagePickerControllerCameraFlashModeOff,但这会导致错误.参考页面说cameraDevice是一个属性.这是否意味着我需要自己创建该属性,还是位于某处?'如果我对代码没有任何操作,但闪光模式设置为自动,则相机正常工作...
显然有一些我不理解的东西.:/
可能重复:
从C#控制相机设备
我有一台笔记本电脑,笔记本电脑的盖子上有内置摄像头。
我想编写一个C#应用程序以捕获图像,并将其保存到硬盘驱动器。
有没有人有一个快速的代码片段来实现这一目标?
我在Windows 7(64位)下运行
我试图将相机的图像用作动态壁纸的一部分.
在我声明的引擎中,我有这个代码:
public class Class extends WallpaperService
{
Camera cam;
@Override
public void onCreate()
{
super.onCreate();
cam = Camera.open();
}
//...
@Override
public Engine onCreateEngine()
{
return new CubeEngine(cam);
}
class CubeEngine extends Engine
{
Camera cam;
CubeEngine(Camera cam)
{
this.cam=cam;
}
//...
@Override
public void onDestroy()
{
if (cam != null)
{
cam.stopPreview();
cam.setPreviewCallback(null);
cam.release();
cam = null;
}
super.onDestroy();
}
@Override
public void onSurfaceChanged(SurfaceHolder holder, int format,
int width, int height)
{
try
{
cam.setPreviewDisplay(holder);
cam.startPreview();
}
catch …Run Code Online (Sandbox Code Playgroud) 我使用Android摄像头并允许用户拍摄静止照片,但我还想让用户切换使用闪光灯的功能.从开/关/自动
此按钮将覆盖在相机上,就像在默认的Android相机应用程序中一样.但我不想使用该应用程序.
我该怎么做?我理解Camera.Parameters,但是如果我在布局上添加了一个按键/值对添加到camera.parameters的按钮,我是否需要刷新相机?我最终会尝试这个(有时只是键入问题可以帮助我提出想法),但任何见解都会受到赞赏!
我的iOS应用程序应该同时执行以下两个任务:
换句话说:我正在寻找被AR标记包围的QR标签.
这两项任务都应该"实时"运行.我的第一个天真的方法表明,在一个应用程序中将两个SDK组合将导致首次初始化的SDK在初始化第二个SDK时停止工作.
有人有建议吗?谢谢.
这是我提供UIImagePickerController的代码:
// Show the media browser with our settings, then the browser will call our delegate if needed
- (BOOL) startMediaBrowserFromViewController: (UIViewController*) controller
usingDelegate: (id <UIImagePickerControllerDelegate,
UINavigationControllerDelegate>) delegate {
if (([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum] == NO)
|| (delegate == nil)
|| (controller == nil))
return NO;
UIImagePickerController *mediaUI = [[[UIImagePickerController alloc] init] autorelease];
mediaUI.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
// Check for images type
NSArray * availableTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeSavedPhotosAlbum];
BOOL imgsOnlyAvailable = NO;
// Check if we have only images
for (int i …Run Code Online (Sandbox Code Playgroud) 我需要在我的应用中使用iPhone Flash灯.但是,当用户打开闪光灯时,相机不会拍照.我怎样才能做到这一点?在这里,我附上了我的代码.但是,当我打开闪光灯时,相机会拍照.
AVCaptureDeviceInput *flashInput = [AVCaptureDeviceInput deviceInputWithDevice:device error: nil];
AVCaptureVideoDataOutput *output = [[AVCaptureVideoDataOutput alloc] init];
AVCaptureSession *session = [[AVCaptureSession alloc] init];
[session beginConfiguration];
[device lockForConfiguration:nil];
[device setTorchMode:AVCaptureTorchModeOn];
[device setFlashMode:AVCaptureFlashModeOn];
[session addInput:flashInput];
[session addOutput:output];
[device unlockForConfiguration];
[output release];
[session commitConfiguration];
[session startRunning];
[self setTorchSession:session];
Run Code Online (Sandbox Code Playgroud)
我在编码时错在哪里?请帮我.提前致谢.
我刚刚开始使用Three.js.就像现在一样.
玩了一个小时左右,并构建了一个工具,帮助我了解不同元素如何协同工作(相机,光,物体),我发现了一些奇怪的东西.
该工具:http://hotblocks.nl/tests/three/cubes.html
这是当前的默认设置:
如您所见,对象位于视口的最底部.所以我想向下转动相机,所以我可以看到更多相机.
试试看:camera.rotation.x拒绝.
这是有效的,但旋转角度是错误的!而不是相机旋转,它是围绕其Z轴旋转的世界.
那不对,是吗?
Y轴也是错误的.它围绕Y轴旋转世界.
围绕Z轴旋转相机,效果很好:相机旋转,而不是世界.
我做错了吗?或者理解错了?
PS由于相机旋转仅围绕其Y轴,因此对象的垂直边缘也应在结果中垂直.在默认设置中,它们是.围绕X轴旋转相机不应该改变它,但确实如此.只绕其Z轴旋转应该改变它(它确实).我错了吗?
PPS我知道Camera.lookAt( THREE.Vector3 target ),但它改变了相机的旋转,包括其Z轴,这在逻辑上是不必要的.