由于我是opencv的新手,我不知道如何将这个cv.CalcEMD2
函数用于numpy
数组.
我有两个数组:
a=[1,2,3,4,5]
b=[1,2,3,4]
Run Code Online (Sandbox Code Playgroud)
我怎么能转移numpy array
到CVhistogram
从Cvhistogram
该函数的参数signature
?
我希望任何回答问题的人opencv
通过提供的解决方案解释任何使用过的功能.
"EMD"== 地球移动者的距离.
更新: -
此外,如果有人可以告诉我如何设置cv.CalcEMD2
参数,即"signature"
使用numpy
数组!!
注意: -
*对于那些可能对此问题感兴趣的人,此答案需要更多测试.
我正在使用Rails 3.1.1和PostgreSQL 9.1以及地球距离模块.为了能够正确计算不同位置之间的距离,我earth
在branches
表格中设置了一个类型的列.
我现在遇到的问题是我的Rails应用程序使用此表不理解地球类型,因此我得到了这个db/schema.rb
:
# Could not dump table "branches" because of following StandardError # Unknown type 'earth' for column 'location'
这是有问题的,因为现在我无法从schema.rb创建我的测试数据库.
如何将此类型添加到AR或使其忽略该列?
我正在研究pArk Apple示例代码,以及它是如何工作的.谁知道如何将纬度和经度转换为ECEF坐标,并将Covert ECEF转换为以给定lat为中心的ENU坐标,lon函数是否有效?我只是想了解这个功能发生了什么!
谢谢.
void latLonToEcef(double lat, double lon, double alt, double *x, double *y, double *z)
{
double clat = cos(lat * DEGREES_TO_RADIANS);
double slat = sin(lat * DEGREES_TO_RADIANS);
double clon = cos(lon * DEGREES_TO_RADIANS);
double slon = sin(lon * DEGREES_TO_RADIANS);
double N = WGS84_A / sqrt(1.0 - WGS84_E * WGS84_E * slat * slat);
*x = (N + alt) * clat * clon;
*y = (N + alt) * clat * slon;
*z = (N * (1.0 …
Run Code Online (Sandbox Code Playgroud) 拜托,你能解释一下earth_box函数的这种行为......或者我做错了什么?
使用的数据
40.749276, -73.985643 = Empire State Building - is in my table
40.689266, -74.044512 = Statue of Liberty - is my current position in select - 8324m far from Empire State Building
Run Code Online (Sandbox Code Playgroud)
我的桌子
=> select id, latitude, longitude, title from requests;
id | latitude | longitude | title
----+-----------+------------+-----------------------
1 | 40.749276 | -73.985643 | Empire State Building
Run Code Online (Sandbox Code Playgroud)
从帝国大厦到自由女神像的距离
=> SELECT id, latitude, longitude, title, earth_distance(ll_to_earth(40.689266, -74.044512), ll_to_earth(latitude, longitude)) as distance_from_current_location FROM requests ORDER BY distance_from_current_location ASC;
id | …
Run Code Online (Sandbox Code Playgroud) 我猜它使用的单位是米(m),但从我发现的文档中看起来并不清楚.它是否正确?
如果是这样,只是为了验证,为了在英里/米之间进行转换,我假设这些功能应该起作用:
public static function mi2m($mi) { // miles to meters
return $mi * 1609.344;
}
public static function m2mi($m) { // meters to miles
return $m * 0.000621371192;
}
Run Code Online (Sandbox Code Playgroud) 我有一个位置表,我的应用程序的用户需要能够搜索.位于"我x英里内的位置"
我正在使用这样的查询:
select * from job_locations
where earth_box(ll_to_earth(51.5, -0.085), 5000) @> ll_to_earth(latitude, longitude)
and earth_distance(ll_to_earth(51.5, -0.085), ll_to_earth(latitude, longitude)) < 5000;
Run Code Online (Sandbox Code Playgroud)
和这样的索引:
CREATE INDEX job_locations_lat_lng on job_locations USING gist(ll_to_earth(latitude, longitude));
Run Code Online (Sandbox Code Playgroud)
但是,这是一个多租户系统,其中所有表都有一个"tenant_id"字段,我们也总是按此过滤.理想情况下,我可以在索引中同时使用tenant_id和ll_to_earth(lat,lng),这可能会使搜索速度更快.
这可能吗?如何创建该索引?
谢谢!
丹尼尔
我正在使用Postgresql 9.3和iv'e安装了cube和earthdistance扩展.
我正在尝试按照本教程,所以我有一个简单的事件表,包含4个字段:id,name,lat,lng.
现在我正在尝试运行此查询,以获取半径1公里范围内的所有事件:
SELECT events.id, events.name FROM events WHERE earth_box(31.789225, 34.789612, 1000) @> ll_to_earth(events.lat, events.lng);
Run Code Online (Sandbox Code Playgroud)
但我一直收到这个错误:
20:59:34 Kernel error: ERROR: function earth_box(numeric, numeric, integer) does not exist
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
Run Code Online (Sandbox Code Playgroud)
所以我用铸造运行同样的东西:
SELECT events.id, events.name FROM events WHERE earth_box(CAST(31.789225 AS float8), CAST(34.789612 AS float8), 1000) @> ll_to_earth(events.lat, events.lng);
Run Code Online (Sandbox Code Playgroud)
我得到:
21:16:17 Kernel error: ERROR: function earth_box(double precision, double precision, integer) does not exist
^ …
Run Code Online (Sandbox Code Playgroud) 我正在开发一个 Android 应用程序,其服务器端是用 Java 编写的。当我收到用户的坐标时,我正在检索餐馆列表,我正在计算距用户的距离,并以升序方式对它们进行排序。
现在,一切正常。唯一的问题是计算的距离具有非常高的灵敏度。我正在寻找的是,以这种方式显示的距离,即 1.2km、200m、12.2km 等,它正在计算并适当地附加公里或米。我怎样才能实现这个目标?
当前输出是:
Restaurant distance is 6026.203669933703
Restaurant distance is 1.0248447083638768
Restaurant distance is 1.0248447083638768
Restaurant distance is 1.0248447083638768
Run Code Online (Sandbox Code Playgroud)
计算和排序代码:
@Override
public List<Restaurant> getNearbyRestaurants(double longitude, double latitude) {
final int R = 6371; // Radius of the earth
List<Restaurant> restaurantList = this.listRestaurants();
List<Restaurant> nearbyRestaurantList = new ArrayList<>();
for(Restaurant restaurant : restaurantList){
Double latDistance = toRad(latitude-restaurant.getLatitude());
Double lonDistance = toRad(longitude-restaurant.getLongitude());
Double a = Math.sin(latDistance / 2) * Math.sin(latDistance / 2) +
Math.cos(toRad(latitude)) * Math.cos(toRad(restaurant.getLatitude())) * …
Run Code Online (Sandbox Code Playgroud) postgresql ×4
gps ×2
activerecord ×1
android ×1
geospatial ×1
gis ×1
histogram ×1
indexing ×1
java ×1
location ×1
numpy ×1
objective-c ×1
opencv ×1
python ×1