我"react-native-vision-camera": "^2.15.4",在我的 Expo 项目中使用(SDK 46,RN,0.69.9)。该expo-camera模块不支持不同的镜头,因此需要切换。
当我以纵向或横向方向拍照时,照片显示为photo.metadata.Orientation: 6
这让我很惊讶。
我希望在拍摄照片后旋转图像的预览,使其水平且更易于查看。它也垂直保存,因此在网络上,它的旋转也错误。
<Camera
// Do not add enableZoomGesture since using the Animated lib
// enableZoomGesture
ref={cameraRef}
photo
device={device}
isActive={isActive}
format={formats?.[0]}
animatedProps={animatedProps}
orientation={'portrait'}
/>
Run Code Online (Sandbox Code Playgroud)
显然,相机组件中的orientation道具也没有按预期运行。
为什么元数据上的方向相同?如何让照片在拍摄后正确旋转,以便保存为以水平“纵向”方向查看?
编辑此后我尝试过react-native-orientation-locker. 虽然它不会锁定正在捕获的图像,但我至少可以在捕获事件之后自定义图像:
const capturePhoto = async () => {
if (cameraRef?.current && !snapping) {
setSnapping(true);
const photo = await cameraRef.current.takePhoto({
flash: flashMode,
});
let rotation = 0;
if (orientation === OrientationType['LANDSCAPE-LEFT']) {
rotation = -90;
} else if …Run Code Online (Sandbox Code Playgroud) react-native expo react-native-vision-camera react-native-orientation-locker
我正在尝试在 iOS 上设置我的 React Native 应用程序,但在构建时,我总是收到此错误:
找不到“react/bridging/CallbackWrapper.h”文件
我自己查了一下,发现有几个人有同样的问题:
我已经尝试了这些答案中的所有内容,但没有运气。由于它似乎与 React Native Vision Camera 有关,因此我也做了他们的故障排除页面中所述的所有操作。
不幸的是我仍然收到错误。我使用npx react-native run-ios(这会引发无尽的错误)和 XCode 本身构建了该项目,我可以在其中找到真正的错误。
你能帮助我吗?该应用程序在 Android 上完美运行。谢谢!
我正在通过构建一个可以拍照并在图库中显示图像的应用程序来学习 React Native。
我用来react-native-vision拍照并按照此答案react-native-fs中的建议访问临时文件,并将其用作uri<Image/>
但是,应该显示列表的视图</Image>显示空白
这是我的代码:
// saves photo on Array and closes the Camera View
const onPressButton = async () => {
console.log(cameraRef.current);
console.log(123);
const photo = await cameraRef.current.takePhoto({
flash: 'off',
qualityPrioritization: 'speed',
});
console.log(photo);
setPhotos([...photos, photo]);
setShowCamera(false);
return;
};
// how I'm trying to render the photos
{photos && photos.length > 0 && (
<View style={{width: '50%', height: '50%'}}>
{photos.map((photo, index) => (
<View key={index}>
{console.log('file://' + DocumentDirectoryPath + …Run Code Online (Sandbox Code Playgroud)