相机捕捉的方向检测
一段时间以来,我一直在寻找解决方案,并且相信从本质上讲,这是不可能的。
我想知道是否有人找到了合适的黑客或绕过方法。
我的问题是这样的:
我有一个应用程序可以捕获照片,然后将该照片用作画布,用户可以点击该画布来放置标签。
放置标签后,用户上传照片,并将标签提交给客户端服务进行解析。
如果照片是横向拍摄的,我需要检测它是横向左还是横向右,以便当它到达画布时我可以以正确的方向显示它,并在用户更改为正确的方向时将其翻转到正确的方向相反的横向模式。
我如何捕捉照片拍摄的方向?
I've been searching for a solution to this for some time and believe that it, at it's core, isn't possible.
I'm wondering if anybody has found a decent hack or bypass.
My issue is this:
I have an app that captures a photo, then that photo is used as a canvas that the user can tap on to place tags.
After the tags are placed the user uploads the photos and the tags get submitted to a client service for parsing.
If the photo is taken in landscape I need to detect if it's landscape left or landscape right so that I can display it at the proper orientation when it gets to the canvas, and flip it the proper direction if the user changes to the opposite landscape mode.
How could I capture the orientation that the photo was taken in?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需查看
event.media
的高度和宽度即可至少确定纵向与横向。这不会帮助您确定要翻转的方向,尽管我不确定为什么您需要从捕获中弄清楚这一点。图像以正确的自然方向保存为风景照片,以便您只需将其旋转到手机的当前方向Simply look at the height and width of
event.media
to at least determine portrait vs. landscape. This will not help you with which direction to flip, though I'm not sure why you need to figure that out from the capture. The image is saved as a landscape photo in the correct natural orientation, such that you would simply rotate it to the current orientation of the phone对 KS 进行了一些修改,但应该可以解决问题。
这应该做上面没有做的事情
modified a bit from the KS but should do the trick.
this should do what the above doesn't