I'm trying to use the bilateral filter (not fast bilateral filter) with PCL 1.7, as I have an unordered point cloud. I have been able to make other PCL code snippets work (so it's not the conversion code), and I can't find documentation on how to make this particular filter work. I'm trying the following code, but I get a memory access violation when calling applyFilter:
pcl::PointCloud<pcl::PointXYZI>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZI> ());
// convert from custom format to pcl format
convert(world_pts, left_intensities, cloud);
pcl::search::KdTree<pcl::PointXYZI>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZI>);
pcl::PointCloud<pcl::PointXYZI> cloud_filtered;
pcl::BilateralFilter<pcl::PointXYZI> fbFilter;
fbFilter.setInputCloud(cloud);
fbFilter.setHalfSize(1.0);
fbFilter.setStdDev(0.2);
fbFilter.applyFilter(cloud_filtered);
The function:
void pcl::BilateralFilter< PointT >::applyFilter ( PointCloud & output)
expects a reference to the output point cloud
and thats why you get a memory access violation
use:
fbFilter.applyFilter(*cloud_filtered);
instead ;)
Related
I tried to make a query from real time database using equalTo().
database.getReference(verifiedProductsDb.dbPartVerifiedProducts).order By Child(verifiedProductsDb.barcode).equalTo(b.toLong()).get().addOnCompleteListener {
but android studio gives out:
None of the following functions can be called with the argument supplied.
equalTo(Boolean) defined in com.google.firebase.database.Query
equalTo(Double) defined in com.google.firebase.database.Query
equal To(String?) defined in com.google.firebase.database.Query
Despite the fact that using setValue, long values are written to the same database quite successfully and without problems.
The Realtime Database API on Android only has support for Double number types. The underlying wire protocol and database will interpret the long numbers correctly though, so you should be able to just do:
database.getReference("VerifiedProducts")
.orderByChild("barcode")
.equalTo(b.toLong().toDouble()) // 👈
.get().addOnCompleteListener {
...
Is it possible to store MAP as a value into MULTIMAP in the Hazelcast ?
please find sample code below,
Map<String , String > userSessionData = client.getMap("userSessionData");
userSessionData.put(userId, userData.getSessionId());
MultiMap <String , Map <String , String >> institutionUsersData = client.getMultiMap( "institutionUsersData" );
institutionUsersCache.put(institutionName,userSessionData);
While trying with above code it's throwing exceptions below,
com.hazelcast.nio.serialization.HazelcastSerializationException: Failed to serialize 'com.hazelcast.client.proxy.ClientMapProxy'
at com.hazelcast.internal.serialization.impl.SerializationUtil.handleSerializeException(SerializationUtil.java:82)
at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toBytes(AbstractSerializationService.java:157)
at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toBytes(AbstractSerializationService.java:133)
at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toData(AbstractSerializationService.java:118)
at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toData(AbstractSerializationService.java:106)
at com.hazelcast.client.spi.ClientProxy.toData(ClientProxy.java:98)
at com.hazelcast.client.proxy.ClientMultiMapProxy.put(ClientMultiMapProxy.java:112)
Caused by: com.hazelcast.nio.serialization.HazelcastSerializationException: There is no suitable serializer for class com.hazelcast.client.proxy.ClientMapProxy
at com.hazelcast.internal.serialization.impl.AbstractSerializationService.serializerFor(AbstractSerializationService.java:487)
at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toBytes(AbstractSerializationService.java:146)
Hazelcast maps are deliberately not serializable, as they are remote & concurrent. The content will change due to inserts/updates/deletes from other clients using the map.
You can take a snapshot if you retrieve the map's entrySet().
This might be larger than the client can cope with.
To store this snapshot back into Hazelcast, it'd need to go in a serializable collection, such as HashMap.
If it's sessions, such a snapshot would show users at a cerrtain point in time, and not change as users log in and out.
I want to filter out the points in a point cloud with a certain 'r' value.
I looked at the documentation, and noticed pcl/filters/color.h is no longer available in PCL 1.7 and above, which is puzzling. (http://docs.pointclouds.org/1.3.1/classpcl_1_1_color_filter.html).
I can probably do this with a naive for loop, but was wondering if there is a way using the pass-through filter conditions, as that is probably multithreaded.
I ended up using conditional_removal, there is a template specialization for RGB. Here is a snippet where we get a ROS point cloud called cloud_msg.
#include <pcl/filters/conditional_removal.h> //and the other usuals
pcl::PointCloud<pcl::PointXYZRGB>::Ptr rgb_cloud(new pcl::PointCloud<pcl::PointXYZRGB>);
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_filtered(new pcl::PointCloud<pcl::PointXYZRGB>);
pcl::fromROSMsg(*cloud_msg, *rgb_cloud);
pcl::PCLPointCloud2 cloud_filtered_ros;
pcl::ConditionalRemoval<pcl::PointXYZRGB> color_filter;
pcl::PackedRGBComparison<pcl::PointXYZRGB>::Ptr
red_condition(new pcl::PackedRGBComparison<pcl::PointXYZRGB>("r", pcl::ComparisonOps::GT, 90));
pcl::ConditionAnd<pcl::PointXYZRGB>::Ptr color_cond (new pcl::ConditionAnd<pcl::PointXYZRGB> ());
color_cond->addComparison (red_condition);
// Build the filter
color_filter.setInputCloud(rgb_cloud);
color_filter.setCondition (color_cond);
color_filter.filter(*cloud_filtered)
I am using the swift 4 language and geofire library to find points on the map within 3000 km of where I am.
When the query encounters the latitude point 90,500 and longitude 100,000 the following error appears: "Not a valid geo location". The crash happens in the "query.observe(.keyEntered" line
query? = geoFire.query (at: self.currentLocation.newLocation !, withRadius: self.distance) {
//code
}
//The crash happens on this line:
var queryHandler = query.observe(.keyEntered, with: {(key, location) in
//Code
})
My question is, how can I handle this kind of error? Do I need to remove all incorrect coordinates from the database? Apparently the function "observe(.keyEntered" does not allow to handle exceptions. I would like to handle the exceptions without the app breaking
It seems like you're hitting the problem described in this issue on the Github repo: https://github.com/firebase/geofire-objc/issues/64
From what I see there, the only option is to reduce the radius of the query.
I have the following script which is being used in a spreadsheet to calculate the driving distance between two cities or a city and a zip code of another city. It is being run for approximately 25 locations simultaneously. To better explain, I have cell B3 in which I enter a new city every time. The script is then used in cells adjacent to my 25 plant locations to calculate the distance from each of my plants to the variable city.
It uses google sheets built in mapping api and works on 80% of the calculations but returns "TypeError: Can Not Read Property "legs" from undefined. (line 16). The plants that it fails on vary with every new city so its not like it is for certain locations. It is almost like the api times out before it completes some of them. I split it into two separate scripts with a varied name and that worked for a day but then 20% fail again.
To make things slightly more odd, I have another script that sorts the plants based on closest distance to the variable address. When you sort the plants, even the ones with errors go to their correct location based on distance. So it is like the distance script is obtaining the correct disance but displaying the error anyways.
Clear as mud? Would love any input I could get on how to correct the issue or an alternate mapping api that could solve my problems.
function distancecalcone(origin,destination) {
var directions = Maps.newDirectionFinder()
//Set the Method of Transporation. The available "modes" are WALKING, DRIVING, BICYCLING, TRANSIT.
.setMode(Maps.DirectionFinder.Mode.DRIVING)
//Set the Orgin
.setOrigin(origin)
//Set the Destination
.setDestination(destination)
//Retrieve the Distance
.getDirections();
return directions.routes[0].legs[0].distance.value/1609.34;
}
Have you tried using a try-catch block around directions.routes[0].legs[0].distance.value ?
try{
return directions.routes[0].legs[0].distance.value/1609.34;
}
catch (e){
console.log("error",e)
}
or you could try something like this
alert(directions);
alert(directions.routes[0]);
alert(directions.routes[0].legs[0]);
alert(directions.routes[0].legs[0].distance);
alert(directions.routes[0].legs[0].distance.value);
and so on...to find out which one comes up as undefined the first. That might help you to debug the issue.
Enable Direction Api
1)Go to "google cloud platform"
2)go to "Api and services"
3)search for "direction api" and enable it
The directions service is subject to a quota and a rate limit. Check the return status before parsing the result.
For lots of distances (or at least more than 10), look at the DistanceMatrix.
I'm able to run the script from the Script editor, but not from spreadsheet. The error is "unable to read property legs" when the function is called from spreadsheet. But the property is in place when called from Script editor and contain correct values.
You probably need to use WEB API and have API KEY:
Google Apps Script - How to get driving distance from Maps for two points in spreadsheet