我试图建立一个相机应用程序(我相当新)当我在真实设备上运行应用程序时它给了我这个错误:
05-26 13:16:37.504 14076-14076/involved.pose9 E/AndroidRuntime: FATAL EXCEPTION: main
Process: involved.pose9, PID: 14076
java.lang.RuntimeException: Fail to connect to camera service
at android.hardware.Camera.<init>(Camera.java:511)
at android.hardware.Camera.open(Camera.java:368)
at involved.pose9.CameraActivity.surfaceCreated(CameraActivity.java:63)
at android.view.SurfaceView.updateWindow(SurfaceView.java:582)
at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:177)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2067)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1119)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6060)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Run Code Online (Sandbox Code Playgroud)
这是我的班级
import android.graphics.PixelFormat;
import android.hardware.Camera;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.Window;
import android.view.WindowManager;
import java.io.IOException;
public …Run Code Online (Sandbox Code Playgroud) 我正在尝试导出来自热像仪的数据,但我收到一条错误消息
error: /build/opencv-ISmtkH/opencv-2.4.9.1+dfsg/modules/highgui/src/cap_ffmpeg.cpp:238: error: (-215) image->depth == 8 in function writeFrame
Run Code Online (Sandbox Code Playgroud)
有人可以看看我在做什么,并告诉我我做错了什么?我非常仔细地跟踪和示例,所以我不明白这个错误意味着什么或者它为什么会发生.
o = camera.add_overlay(np.getbuffer(a), size=(320,240), layer=3, alpha=int(alpha), crop=(0,0,80,60), vflip=flip_v)
filename = time.strftime("%Y.%m.%d %H.%M.%S", time.localtime()) + ".avi"
fourcc = cv2.cv.CV_FOURCC('I','4','2','0')
out = cv2.VideoWriter(filename, fourcc, fps, (width, height))
try:
time.sleep(0.2) # give the overlay buffers a chance to initialize
with Lepton(device) as l:
last_nr = 0
while True:
_,nr = l.capture(lepton_buf)
out.write(lepton_buf)
if nr == last_nr:
# no need to redo this frame
continue
last_nr = nr
cv2.normalize(lepton_buf, lepton_buf, 0, 65535, …Run Code Online (Sandbox Code Playgroud) 我在Android中使用Camera API 2并尝试应用自动对焦功能.自动对焦与后置摄像头正常工作,但前置摄像头无法正常工作.
(我使用的是Android 5.1和6.0设备)
详情:
这是启动自动对焦的触发器:
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_START);
Run Code Online (Sandbox Code Playgroud)
这是CameraCaptureSession.CaptureCallback
Integer afState = result.get(CaptureResult.CONTROL_AF_STATE);
Run Code Online (Sandbox Code Playgroud)
如果我使用前置摄像头,afState的值总是0(非活动).但是使用后置摄像头,该值从2(CONTROL_AF_STATE_PASSIVE_FOCUSED - 尝试聚焦)变为4(焦点成功时CONTROL_AF_STATE_FOCUSED_LOCKED)或5(焦点失败时CONTROL_AF_STATE_NOT_FOCUSED_LOCKED).
你们有没有想过为什么我不能在前置摄像头上使用自动对焦?
以下代码在使用相机拍摄照片时效果很好,但是当用户点击视频时应用程序崩溃.
let imagePicker = UIImagePickerController()
imagePicker.modalPresentationStyle = .currentContext
imagePicker.delegate = self
if let _ = UIImagePickerController.availableMediaTypes(for: .camera) {
imagePicker.mediaTypes = UIImagePickerController.availableMediaTypes(for: .camera)!
if UIImagePickerController.isSourceTypeAvailable(.camera) {
imagePicker.sourceType = .camera
present(imagePicker, animated: true, completion: nil)
}
}
Run Code Online (Sandbox Code Playgroud) 我的目标是从相机中获取最大数量的图像而不保存它们,但我不知道如何进行这种操作.我知道如何从拍摄照片的相机中捕捉到一张图像,但是我是如何在不拍照的情况下从相机中获取照片的?
我不会通过互联网发送照片,而是在设备上处理它们.我必须拍摄视频或照片序列吗?
在使用相机的应用程序中,我需要显示相机的预览,我可以通过获取所有支持的预览尺寸并找到最佳预览尺寸来设置预览尺寸.我还应该为相机设置最佳图片尺寸吗?如果是这样,预览大小和图片大小有什么区别?
目前我使用以下内容来查找最佳预览尺寸
int minDiff = Integer.MAX_VALUE;
for (SizePair sizePair : validPreviewSizes) {
Size size = sizePair.previewSize();
int diff =
Math.abs(size.getWidth() - desiredWidth) + Math.abs(size.getHeight() - desiredHeight);
if (diff < minDiff) {
selectedPair = sizePair;
minDiff = diff;
}
}
Run Code Online (Sandbox Code Playgroud)
使用此方法会在某些手机中提供错误的预览尺寸.有人可以建议一个更好的逻辑来获得最佳的preivew大小?
我有一个PTGrey FL3-U3-13E4C-C USB 3相机。我可以从PTGrey提供的默认代码读取和存储单个摄像机的图像。
但是,当我尝试在连接了2个摄像机的情况下运行MultipleCameraEx进行测试时,出现“等时启动失败”错误。
我尝试将摄像机的数量手动设置为2,并在没有for循环的情况下运行代码,但对于2台摄像机,我仍然遇到相同的错误。
我收到以下错误。
FlyCapture2库版本:2.10.3.266应用程序生成日期:2017年4月8日17:45:42
检测到的摄像机数量:2
*摄像机信息* 序列号-16362359摄像机型号-Flea3 FL3-U3-13E4C摄像机供应商-点灰度研究传感器-E2v EV76C560(1 / 1.8英寸彩色CMOS)分辨率-1280x1024固件版本-2.15.3.3固件构建时间-周三29 16:41:55 2015年
*摄像机信息* 序列号-16362353摄像机型号-Flea3 FL3-U3-13E4C摄像机供应商-点灰度研究传感器-E2v EV76C560(1 / 1.8英寸彩色CMOS)分辨率-1280x1024固件版本-2.15.3.3固件构建时间-周三29 16:41:55 2015年
错误跟踪:源:IidcCameraInternal.cpp(469)内置:2016年10月20日20:17:21-启动同步流时出错。+->来自:Iso.cpp(2046)内置:2016年10月20日20:16:34-等时启动失败。错误:0x2。
我正在尝试遵循此处给出的答案:https : //stackoverflow.com/a/32381052/8422218创建一个使用背面摄像头并添加滤镜的应用,然后将其实时显示在屏幕上
这是我的代码:
//
// ViewController.swift
// CameraFilter
//
import UIKit
import AVFoundation
class ViewController: UIViewController, AVCaptureVideoDataOutputSampleBufferDelegate {
var captureSession = AVCaptureSession()
var backCamera: AVCaptureDevice?
var frontCamera: AVCaptureDevice?
var currentCamera: AVCaptureDevice?
var photoOutput: AVCapturePhotoOutput?
var cameraPreviewLayer: AVCaptureVideoPreviewLayer?
@IBOutlet weak var filteredImage: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
setupCaptureSession()
setupDevice()
setupInputOutput()
setupCorrectFramerate(currentCamera: currentCamera!) // will default to 30fps unless stated otherwise
setupPreviewLayer()
startRunningCaptureSession()
}
func setupCaptureSession() {
// should support anything up to 1920x1080 res, incl. 240fps @ …Run Code Online (Sandbox Code Playgroud) ARCore相机似乎不支持takePicture. https://developers.google.com/ar/reference/java/com/google/ar/core/Camera
谁知道我怎么能用ARCore拍照?
我正在尝试使用以下代码从手机的相机拍摄照片:
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/btnCapture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Camera" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
MainActivity.java:
public class CameraDemoActivity extends Activity {
int TAKE_PHOTO_CODE = 0;
public static int count = 0;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Here, we are making a folder named picFolder to store
// pics taken by the camera using this application.
final String dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/picFolder/";
File …Run Code Online (Sandbox Code Playgroud) camera ×10
android ×6
ios ×2
opencv ×2
swift ×2
arcore ×1
autofocus ×1
bitmap ×1
c++ ×1
camera-api ×1
core-image ×1
file ×1
front-camera ×1
python ×1