且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何修改此脚本以连续拍摄照片?

更新时间:2023-12-05 19:33:46

Afaik,您不能每帧都进行新的TakePhotoAsync调用,但必须等到当前过程完成为止.这是对性能的强烈要求,afaik还获得了访问摄像头设备的专有许可,因此任何其他呼叫均会失败.

Afaik you can not make a new TakePhotoAsync call every frame but have to wait until the current process finished. It is to performance intense and afaik also gets exclusive permission to access the camera device so any other call fails meanwhile.

为了等待下一张照片,直到在OnCapturedPhotoToMemory中完成照片之前,您可以简单地代替

In order to wait with the next photo until before one is finished in OnCapturedPhotoToMemory you could simply instead of

photoCaptureObject.StopPhotoModeAsync(OnStoppedPhotoMode);

调用下一张照片

photoCaptureObject.TakePhotoAsync(OnCapturedPhotoToMemory);


也许您应该像在private bool shouldStop之类的


Maybe you should add an exit condition right before it like a private bool shouldStop like

if(shouldStop)
{
    photoCaptureObject.StopPhotoModeAsync(OnStoppedPhotoMode);
}
else
{
    photoCaptureObject.TakePhotoAsync(OnCapturedPhotoToMemory);
}


但是,请注意,这将大大降低您的应用程序的速度!由于大多数Texture2D内容都发生在主线程上,因此性能非常高!


However, be aware that this will slow down your App drastically! Since most of the Texture2D stuff happens on the main thread and is quite performance intense!