PCL Color Filter - point-cloud-library

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)

Related

How do I make a query equalto with a long value?

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 {
...

Getting ProjectBOs from CatalogCategoryBO returns different results based on BusinessObjectRepositoryContext

We are trying to get all ProductBOs from CatalogCategoryBO with following code:
final CatalogBORepository catalogBORepository = applicationBO.getRepository("CatalogBORepository");
final CatalogCategoryBO catalogCategoryBO = catalogBORepository.getCatalogBOByCatalogName(catalogName).getCatalogCategoryBOByName(catalogCategoryName);
final CatalogCategoryBOCommonProductAssignmentExtension assignmentExtension = catalogCategoryBO.getExtension(CatalogCategoryBOCommonProductAssignmentExtension.class);
return assignmentExtension.getSortedProducts(applicationBO.getDefaultLocale());
But this does not always work as expected. After debugging I found out that main reason is BusinessObjectRepositoryContext:
((BusinessObjectRepositoryContext)catalogCategoryBO.getContext().getVariable("CurrentBusinessObjectRepositoryContext");
which is different based on location from which we call given method (organization or channel).
The same problem is described here: https://support.intershop.com/kb/index.php/Display/IS-22604
Is there some workaround or better way to get all assigned ProductBOs from CatalogCategoryBO?
We are using Intershop B2C version 7.9.1.2.
One possibility is to call pipeline for getting products as suggested by Willem Evertse, another one is to fetch CatalogBORepository and CatalogCategoryBO within block of:
try (ApplicationContext applicationContext = application.forceApplicationContext()) {
// your code here
}
https://support.intershop.com/kb/index.php/Display/2X3516#Concept-ApplicationFramework-TheExecutionContextofanApplication
Yes, this is because the business objects can have different implementations depending on the context (application).
If you look at how the rest api does it (see ProductListResource) they call the ProductHandler (see ProductHandlerImpl) method:
getProducts(Domain currentChannel, CatalogCategoryBO category, String searchTerm, String localeId,...)
Only the category parameter is mandatory it seems, the other parameters can be null. The added benefit is that this code will call the Solr index (if u have it enabled) so it should perform better than running a query on the database (which is also a possibility).

How can i iterate over a basic blocks in a specific routine in intel pintool?

I tried to iterate over a basic blocks in a specific routine, but i found some problems:
VOID Routine(RTN rtn, VOID *v)
{
RTN_Open(rtn)
for (BBL bbl = RTN_BblHead(rtn); BBL_Valid(bbl); bbl = BBL_Next(bbl))
{ /* some code */ }
RTN_Close(rtn);
}
error: deprecated-declarations,
How can i fix that error, or do it by another way ?
You have a deprecated-declarations warning because RTN_BblHead is now deprecated. Use RTN_InsHead instead.
From include\pin\gen\image.ph:
/* DO NOT EDIT */
/* RTN_BblHead is now deprecated. See RTN_InsHead.
*/
extern PIN_DEPRECATED_API BBL RTN_BblHead(RTN x);
This is also mentioned in the documentation: RTN_BblHead
You can also pass -Wno-deprecated-declarations to GCC to suppress this warning.
Edit
Remember that PIN is above all a DBI (dynamic binary instrumentation) framework: it is extremely good when it comes to instrument the executed code flow, and less good when it needs to break down non executed code.
Routine instrumentation lets the Pintool inspect and instrument an entire routine when the image it is contained in is first loaded' but as the documentation points:
A Pintool can walk the instructions of a routine. There is not enough
information available to break the instructions into BBLs.
Pin find the instructions of a RTN through static discovery, so Pin cannot guarantee that it will find all the instructions in the RTN and this is even more difficult for BBLs. My guess is that they tried at some point (hence the availability of RTN_BblHead in the past) to provide static discovery of BBLs but the discovery rate was too low (or too error prone) to be deemed acceptable, so the function became deprecated.
In short, yes you need to discover a RTN instructions by instructions (knowing that pin might miss some instructions as this is done statically). You can only discover the BBLs of a routine if the routine is executed at some point.

Using bilateral filter with PCL

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 ;)

Firebase and AngularFire - $add in a array - unexpected behaviour

dayPath = ref.path.toString() + '/' + configId + '/screens/' + screenIndex + '/days/',
// the ref for the days object
daysRef = fbutil.ref(dayPath),
// the sync for the days object
daysSync = fbutil.syncObjectReference(daysRef);
// the collection as a $firebase array
var list = daysSync.$asArray(),
items = [],
number;
console.log(list);
list.$add({dummy: 'Test'});
According with the documentation, when I use $add with $asArray, the $add supposed to do a "push". But instead it's creating a hash key instead a numeric index.
So, the dummy: test has a parent containing a hash key. The expected is a numeric index, I mean : array item.
Can someone give me some help? I just have 1 week of experience in this database.
The result is this one...
screens
...0
.......days
..........0
..........1
..........2
.........-JrT5ZATDELIR3gXAvah
................dummy: test
AngulareFire is built on the Firebase JavaScript SDK. So when AngularFire's documentation says it uses push internally, it is not referring to JavaScript's Array.push, but to Firebase's push operation. And Firebase's push generates its own keys, it does not generate regular array indexes.
The reason for that is best explained in Firebase's documentation on arrays, but essentially boils down to: arrays don't work well in distributed environments, because all clients have to agree on the array.length in order to be able to add a new item.
So $firebaseArray.$add will generated a so-called push ID. They are ordered, like array indexes, but can be generated across clients without risk of conflicts.
I noticed that you're on a somewhat older version of AngularFire. I highly recommend that you follow the "official" quickstart and guide for AngularFire.
I would like to comment but i don't have enough reputation yet so i'm doing it here.
The solution in my eyes is very simple:
Instead of:
list.$add({dummy: 'Test'});
Do:
list[index] = {dummy: 'Test'};

Resources