最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

女友半夜加班發(fā)自拍 python男友用30行代碼發(fā)現(xiàn)驚天秘密

 更新時(shí)間:2021年08月19日 15:13:10   作者:LexSaints  
大家好,我是Lex 喜歡欺負(fù)超人那個(gè)Lex 女友說(shuō)今晚加班,還給我發(fā)了一張照片? 我心生懷疑,就用python分析了一下照片,結(jié)果發(fā)現(xiàn)。。。 劃重點(diǎn):利用Python讀取照片的GPS信息信息

事情是這樣的

正準(zhǔn)備下班的python開(kāi)發(fā)小哥哥

接到女朋友今晚要加班的電話(huà)

并給他發(fā)來(lái)一張背景模糊的自拍照

如下 ↓ ↓ ↓

敏感的小哥哥心生疑竇,難道會(huì)有原諒帽

然后python擼了一段代碼 分析照片

分析下來(lái) emmm

拍攝地址居然在 XXX酒店

小哥哥崩潰之余 大呼上當(dāng)

python分析照片

小哥哥將發(fā)給自己的照片原圖下載下來(lái)

并使用python寫(xiě)了一個(gè)腳本

讀取到了照片拍攝的詳細(xì)的地址

詳細(xì)到了具體的街道和酒店名稱(chēng)

引入exifread模塊

首先安裝python的exifread模塊,用于照片分析

pip install exifread 安裝exfriead模塊

PS C:\WINDOWS\system32> pip install exifread
Collecting exifread
  Downloading ExifRead-2.3.2-py3-none-any.whl (38 kB)
Installing collected packages: exifread
Successfully installed exifread-2.3.2
PS C:\WINDOWS\system32> pip install json

GPS經(jīng)緯度信息

其實(shí)我們平時(shí)拍攝的照片里,隱藏了大量的私密信息

包括 拍攝時(shí)間、極其精確 具體的GPS信息。

下面是通過(guò)exifread模塊,來(lái)讀取照片內(nèi)的經(jīng)緯度信息。

#讀取照片的GPS經(jīng)緯度信息
def find_GPS_image(pic_path):
    GPS = {}
    date = ''
    with open(pic_path, 'rb') as f:
        tags = exifread.process_file(f)
        for tag, value in tags.items():
            #緯度
            if re.match('GPS GPSLatitudeRef', tag):
                GPS['GPSLatitudeRef'] = str(value)
            #經(jīng)度
            elif re.match('GPS GPSLongitudeRef', tag):
                GPS['GPSLongitudeRef'] = str(value)
            #海拔
            elif re.match('GPS GPSAltitudeRef', tag):
                GPS['GPSAltitudeRef'] = str(value)
            elif re.match('GPS GPSLatitude', tag):
                try:
                    match_result = re.match('\[(\w*),(\w*),(\w.*)/(\w.*)\]', str(value)).groups()
                    GPS['GPSLatitude'] = int(match_result[0]), int(match_result[1]), int(match_result[2])
                except:
                    deg, min, sec = [x.replace(' ', '') for x in str(value)[1:-1].split(',')]
                    GPS['GPSLatitude'] = latitude_and_longitude_convert_to_decimal_system(deg, min, sec)
            elif re.match('GPS GPSLongitude', tag):
                try:
                    match_result = re.match('\[(\w*),(\w*),(\w.*)/(\w.*)\]', str(value)).groups()
                    GPS['GPSLongitude'] = int(match_result[0]), int(match_result[1]), int(match_result[2])
                except:
                    deg, min, sec = [x.replace(' ', '') for x in str(value)[1:-1].split(',')]
                    GPS['GPSLongitude'] = latitude_and_longitude_convert_to_decimal_system(deg, min, sec)
            elif re.match('GPS GPSAltitude', tag):
                GPS['GPSAltitude'] = str(value)
            elif re.match('.*Date.*', tag):
                date = str(value)
    return {'GPS_information': GPS, 'date_information': date}

百度API將GPS轉(zhuǎn)地址

這里需要使用調(diào)用百度API,將GPS經(jīng)緯度信息轉(zhuǎn)換為具體的地址信息。

這里,你需要一個(gè)調(diào)用百度API的ak值,這個(gè)可以注冊(cè)一個(gè)百度開(kāi)發(fā)者獲得,

當(dāng)然,你也可以使用博主的這個(gè)ak

調(diào)用之后,就可以將拍攝時(shí)間、拍攝詳細(xì)地址都解析出來(lái)。

def find_address_from_GPS(GPS):
    secret_key = 'zbLsuDDL4CS2U0M4KezOZZbGUY9iWtVf'
    if not GPS['GPS_information']:
        return '該照片無(wú)GPS信息'
    #經(jīng)緯度信息
    lat, lng = GPS['GPS_information']['GPSLatitude'], GPS['GPS_information']['GPSLongitude']
    baidu_map_api = "http://api.map.baidu.com/geocoder/v2/?ak={0}&callback=renderReverse&location={1},{2}s&output=json&pois=0".format(
        secret_key, lat, lng)
    response = requests.get(baidu_map_api)
    #百度API轉(zhuǎn)換成具體的地址
    content = response.text.replace("renderReverse&&renderReverse(", "")[:-1]
    print(content)
    baidu_map_address = json.loads(content)
    #將返回的json信息解析整理出來(lái)
    formatted_address = baidu_map_address["result"]["formatted_address"]
    province = baidu_map_address["result"]["addressComponent"]["province"]
    city = baidu_map_address["result"]["addressComponent"]["city"]
    district = baidu_map_address["result"]["addressComponent"]["district"]
    location = baidu_map_address["result"]["sematic_description"]
    return formatted_address,province,city,district,location
 
if __name__ == '__main__':
    GPS_info = find_GPS_image(pic_path='C:/女友自拍.jpg')
    address = find_address_from_GPS(GPS=GPS_info)
    print("拍攝時(shí)間:" + GPS_info.get("date_information"))
    print('照片拍攝:' + str(address))

Python小哥得到的結(jié)果是這樣的

照片拍攝地址:('云南省XXXXXXX縣', '云南省', 'XXXX市', 'XXX縣', 'XXXX酒店')

云南彌勒XXXX酒店,這明顯不是老王女友工作的地方

小哥哥搜索了一下,這是一家溫泉度假酒店。

頓時(shí)就明白了

完整代碼:點(diǎn)此下載

到此這篇關(guān)于女友半夜加班發(fā)自拍 python男友用30行代碼發(fā)現(xiàn)驚天秘密的文章就介紹到這了,更多相關(guān)python讀取GPS內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

城口县| 江城| 曲靖市| 三都| 逊克县| 沙洋县| 湘乡市| 洛阳市| 固原市| 定兴县| 临洮县| 白朗县| 临清市| 河曲县| 东山县| 林甸县| 鄂尔多斯市| 祁连县| 大田县| 泸西县| 平潭县| 蒲江县| 乌苏市| 莲花县| 射阳县| 澄江县| 陆良县| 蓝田县| 渭源县| 土默特左旗| 兰州市| 白河县| 康定县| 台中县| 兖州市| 新建县| 子长县| 呼玛县| 吉林市| 霍山县| 庆城县|