你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

自动GPS控制照片制作器

[复制链接]
木木&点点 发布时间:2019-3-25 22:40
本帖最后由 点点&木木 于 2019-4-12 11:20 编辑 2 b/ e1 f( n3 K, |/ z, |

" ~2 I5 G' D6 i+ E6 B) c
对于这个版本,当我靠近我喜欢的地方时,我把一个背包放在一起拍照。特别是在伦敦。
1.png
/ B' `* s$ x, Q$ G; f
硬件组件
Raspberry Pi 3型号B.       ×       1      
带有3米有源天线的GPS模块U-blox NEO-6M(STM32 51)   × 1      
PNY 7800 PowerPack   ×     1      
GoPro HERO系列相机 ×      1      
GoPro 3-Way     ×      1      

6 q2 n- m' P  G+ c
介绍
" V( b. ?" k  F3 z- N) K7 @
我喜欢旅游。但我不喜欢停下来拍照。但我仍然想要图片。所以我决定制作自己的个人自动GPS控制便携式照片制作工具!
这个项目是一个背包,ta实现当我靠近我预先选择的地方时,自动拍照。此次测试地点选择了伦敦,我想没有其它更好的地方进行测试了!
" j3 m- C  R% H2 ~* C
硬件
我将GPS模块连接到Raspberry Pi(由电池组供电),通过WiFi将信号发送到GoPro。
·  GPS :今天没有焊接!我只是将GPS模块插入Raspberry Pi和USB。
·  WiFi :我打开了GoPro的WiFi并连接了Raspberry Pi。WiFi SSD由GoPro App配置。
·  Raspberry Pi :我将它插入电池组。
搞定!您可以将GoPro Arm添加到您想要的任何内容!我旅行时选择了背包。
) C0 F: H9 e4 u- I/ D) h1 U8 j
软件
我编制了一份我想去伦敦的地方的坐标列表。然后我用Python编写了一个脚本(LondonGPS.py)来计算我所在的坐标和我预选位置的坐标之间的距离。
该脚本在我的Raspberry Pi中启动时运行,因此它可以在我打开电池组时立即开始运行脚本并检查我的坐标。
我发现了这个非常棒的GoPro API库,并用它通过WiFi连接我的GoPro和我的Raspberry Pi。首先,为了让API 工作,我安装了python3。然后我通过pip安装了库:
pip install goprocam
然后,在LondonGPS.py脚本中,我初始化了相机:
camera = GoProCamera.GoPro()
并拍照:
#0 is the time it waits before the picture is taken.camera.take_photo(0)
全球定位系统:
我通过pip安装了gpsd-py3。为了安装和启动gpsd我遵循了这个:https//pypi.python.org/pypi/gpsd-py3/0.2.0。
然后我将gps守护进程指向GPS设备。在我的Pi上,我编辑了文件/etc/rc.local并添加了以下行:
gpsd /dev/ttyACM0 -F /var/run/gpsd.sock
启动:
在我的Pi /etc/rc.local上的同一个文件中,我添加了运行我的脚本的命令。
python3 /home/pi/LondonGPS.py
LondonGPS.py
所有计算都在下面附带的python脚本中进行。
检查出来,制作自己的个人自动GPS控制便携式照片!
评论你的想法以及你要添加的地方!不要忘记订阅我的YouTube频道,让他们成为第一个知道新视频何时播出的人:https ://www.youtube.com/c/estefanniegg。
这是关于组件如何相互交互的图纸。
2.png
3 Z' {" h7 n: N4 Q
代码
#Import all necessary libraries
import time
import gpsd
import math
from goprocam import GoProCamera
from goprocam import constants
#Need this to calculate the where I am
earthRadius = 6371
#Wait for the Pi to boot and get the GoProWifi
time.sleep(20)
#Connect to the local gpsd
gpsd.connect()
#Initialize the camera object
camera = GoProCamera.GoPro()
#Saved Locations for this trip:
#Platform 9 3/4: 51.5322° , -0.1240°
#Abbey Road: 51.5321° , -0.1781°
#Buckingham 51.5014°, -0.1419°
#Big Ben 51.5007° , -0.1246°
#Tower of London 51.5081° , -0.0759°
#Tower Bridge 51.5055° , -0.0754°
#Shakespeare Globe 51.5081° , -0.0972°
#Sweetings 51.5125° , -0.0928°
#Create location arrays:
latitude = [51.5110, 51.5322, 51.5321, 51.5014, 51.5007, 51.5081, 51.5055, 51.5081, 51.5125]
longitude = [-0.1863, -0.1240, -0.1781, -0.1419, -0.1246, -0.0759, -0.0754, -0.0972, -0.0928]
# Main loop to check the coordinates that Iam at
# and the coordinates I’ve saved.
while True:
      received = False
      try:
               packet = gpsd.get_current()
               received = True
      except Exception:
               print("Nosignal")
      if received ==True:
               #get my current position
               currentPost = packet.position()
               currentLat = currentPost[0]
               currentLon = currentPost[1]
               for location in range(len(latitude)):
                 
                       # The angles need to be in radians to pass
                       # to trig functions
                       dLat =math.radians(latitude[location] - currentLat)
                       dLon =math.radians(longitude[location] - currentLon)
                       
                       # I used the ‘haversine’ formula to calculate
                       # the distance between two points over the
                       # earth’s surface.
                       # a = sin²(Δφ/2) + cos φ1 ⋅ cos φ2 ⋅ sin²(Δλ/2)
                       # c = 2 ⋅ atan2( √a, √(1−a) )
                       #d = R ⋅ c
                       a = math.sin(dLat/2) * math.sin(dLat/2) +math.cos(math.radians(latitude[location])) * math.cos(math.radians(currentLat))* math.sin(dLon/2) * math.sin(dLon/2)
                       c = 2 *math.atan2(math.sqrt(a), math.sqrt(1-a))
                       d = earthRadius * c
                       
                       # d is distance between the two sets of coordinates
                       # if distance is less than 10m unit of d is in km,
                       # take a picture
                       if d < 0.01:
                       camera.take_photo(0)
      
      #we need to sleep so it doesn't infinitelypoll
       time.sleep(1)
6 T. P9 K2 r+ L$ s( d
收藏 评论0 发布时间:2019-3-25 22:40

举报

0个回答

所属标签

相似分享

关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新和工艺
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版