目录
- 1. 论文链接
- 2. 安装环境
- 3. 遇到的问题和解决方法
-
- 3.1 第一步运行kde.py
- 3.2 第二步运行skeleton.py
-
- 3.2.1 ImportError: No module named pyximport***
- 3.2.2 Pychorm提示Unresolved reference 导入模块报错
- 3.2.3 ImportError: Building module subiterations failed: ['DistutilsPlatformError: Unable to find vcvarsall.bat\n'](生成模块子迭代失败
- 3.2.4 ImportError: Building module subiterations failed: ["CompileError: command 'C:\\\\Users\\\\87792\\\\AppData\\\\Local\\\\Programs\\\\Common\\\\Microsoft\\\\Visual C++ for Python\\\\9.0\\\\VC\\\\Bin\\\\amd64\\\\cl.exe' failed with exit status 2\n"]
1. 论文链接
Map Inference in the Face of Noise and Disparity
代码下载地址
2. 安装环境
python 2.7.15 win64位
Opencv 2.4.13 win64位 (安装过程可参考windows平台下python安装opencv,即实现import cv2功能)
pycharm 2019.3.3 win64位(来源微信公众号PyCharm2019【中文版】安装教程)
3. 遇到的问题和解决方法
3.1 第一步运行kde.py
#coding:utf-8
import cv2
import cv2.cv as cv
from math import atan2, sqrt, ceil, pi, fmod
import sys, getopt, os
from location import TripLoader
from pylibs import spatialfunclib
from itertools import tee, izip
import sqlite3
##
## important parameters
##
cell_size = 1 # meters
gaussian_blur = 17
trips_path = "trips/trips_1m/"
def pairwise(iterable):
"s -> (s0,s1), (s1,s2), (s2, s3), ..."
a, b = tee(iterable)
next(b, None)
return izip(a, b)
class KDE:
def __init__(self):
pass
def create_kde_with_trips(self, all_trips):
print "trips path: " + str(trips_path)
print "cell size: " + str(cell_size)
print "gaussian blur: " + str(gaussian_blur)
# flag to save images
save_images = True
sys.stdout.write("\nFinding bounding box... ")
sys.stdout.flush()
min_lat = all_trips[0].locations[0].latitude
max_lat = all_trips[0].locations[0].latitude
min_lon = all_trips[0].locations[0].longitude
max_lon = all_trips[0].locations[0].longitude
for trip in all_trips:
for location in trip.locations:
if (location.latitude < min_lat):
min_lat = location.latitude
if (location.latitude > max_lat):
max_lat = location.latitude
if (location.longitude < min_lon):
min_lon = location.longitude
if (location.longitude > max_lon):
max_lon = location.longitude
print "done."
# find bounding box for data
min_lat -= 0.003
max_lat += 0.003
min_lon -= 0.005
max_lon += 0.005
diff_lat = max_lat - min_lat
diff_lon = max_lon - min_lon
#print min_lat, min_lon, max_lat, max_lon
width = int(diff_lon * spatialfunclib.METERS_PER_DEGREE_LONGITUDE / cell_size)
height = int(diff_lat * spatialfunclib.METERS_PER_DEGREE_LATITUDE / cell_size)
yscale = height / diff_lat # pixels per lat
xscale = width / diff_lon # pixels per lon
# aggregate intensity map for all traces
themap = cv.CreateMat(height,width,cv.CV_16UC1)
cv.SetZero(themap)
##
## Build an aggregate intensity map from all the edges
##
trip_counter = 1
for trip in all_trips:
if ((trip_counter % 10 == 0) or (trip_counter == len(all_trips))):
sys.stdout.write("\rCreating histogram (trip " + str(trip_counter) + "/" + str(len(all_trips)) + ")... ")
sys.stdout.flush()
trip_counter += 1
temp = cv.CreateMat(height,width,cv.CV_8UC1)
cv.SetZero(temp)
temp16 = cv.CreateMat(height,width,cv.CV_16UC1)
cv.SetZero(temp16)
for (orig,dest) in pairwise(trip.locations):
oy = height - int(yscale * (orig.latitude - min_lat))
ox = int(xscale * (orig.longitude - min_lon))
dy = height - int(yscale * (dest.latitude - min_lat))
dx = int(xscale * (dest.longitude - min_lon))
cv.Line(temp, (ox, oy), (dx, dy), (32), 1, cv.CV_AA)
# accumulate trips into themap
cv.ConvertScale(temp,temp16,1,0)
cv.Add(themap,temp16,themap)
lines = cv.CreateMat(height,width,cv.CV_8U)
cv.SetZero(lines)
print "done."
trip_counter = 1
for trip in all_trips