Visualizing a (XYZRGBL) .pcd file - point-cloud-library

I have a 'XYZRGBL' point cloud in a .pcd file. I want to visualize it, so I used this code:
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));
viewer->setBackgroundColor (0, 0, 0);
viewer->addPointCloud<pcl::PointXYZRGB> (cloud1, "sample cloud");
viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "sample cloud");
viewer->addCoordinateSystem (1.0);
viewer->initCameraParameters ();
But, I received this error:
no matching function for call to
‘pcl::visualization::PCLVisualizer::addPointCloud(pcl::PointCloudpcl::PointXYZRGBL::Ptr&,
const char [13])
I tried:
viewer->addPointCloud<pcl::PointXYZRGBL>
instead of
viewer->addPointCloud<pcl::PointXYZRGB>
but still same problem.
Does anyone know where is my fault?
Thanks in advance!

At the end you have to add:
while (!viewer->wasStopped ()) {
viewer->spinOnce (100);
boost::this_thread::sleep (boost::posix_time::microseconds (100000)); }
This will show your Point Cloud.

Related

How to add a string to this function in Arduino C?

I've been toying with this code, and been looking up solutions to this problem to no avail. I was told you were to add a string to a function like so in Arduino C++:
myFunction(String myString)
I've seen examples using this as well. This is the chunk of code that is having issues.
if (piezoV >= 0.25) {
Serial.println(piezoV);
// Serial.println(F("Playing track " + tracknum +""));
String file = String(trackid) + String(tracknum) + String(ext);
musicPlayer.playFullFile(String file);
int tracknum = tracknum + 1;
}
The code fetches this error:
musicPlayer.playFullFile(String file); - expected primary-expression before 'file'
I'm new to Arduino C++, and I am using experience from other languages I've learned to help, but I was wondering if SO could help me with this. Thanks in advance.
musicPlayer.playFullFile(String file);
is not a valid way to call a function in C++. You declare the function with types:
void playFullFile(String file) {
doWhateverIsNeededWith(file);
}
but you call it without the type:
String file = "./pax_singing_badly_in_shower.mp3"; // torture user :-)
musicPlayer.playFullFile(file);

Cannot identify language in SALT

I just started using SALT for a project i am working on. It is said to work with Python but I find quite a bit of difference in thier syntax and overall format. I have pasted a code for a simple task which just opens and imports and loads some libraries onto the SALT console. I hope someone can check abnd see if he/she can instantly identify the language being used and what the code does. This is because i have a suspicion that the code is a mixture between C, Python as well as Java... if that is so doen't that mean it should be a totally different language on its own?
code:
var rtwxlib = import'rtwxlib';
var string = import'string';
var monitor = rtwxlib.Monitor
{
EvActivate = func() { print "Activate\n"; };
EvShutdown = func() { print "Shutdown\n"; };
EvProgress = func(self, fDone, msg = "") {
print("Progress: %d %s \r"::format(fDone*100, msg));
};
EvEventMsg = func(self, msg) {
print("\nEvent: %s\n"::format(iStat, msg));
};
};
var solver = rtwxlib.Solver(monitor);
solver::Open("test.wrx");
solver::DelGeometry();
solver::SaveAs('testresults.wrx');
solver::Close();
I was able to indentify the syntax of the language used as C. I beieve the problem I had which confused me was the libraries used for this code which I later found out was for a particular program. Thank you to all those who tried to help though :)

Wrong "Spacing" and "Origin" of a DICOM series in ITK

When I read a dicom series with a series reader in itk,
I always find the origin=[0 0 0] and spacing=[1 1 1], the same for all different datasets.
* main function:-
void main()
{
reader = READ_DCM(Input_DCM_Paths[0]);
cout<<" Reading Done!!"<<endl;
cout<< " Origin: " <<reader->GetOutput()->GetOrigin()<< endl;
cout<< " Spacing: " <<reader->GetOutput()->GetSpacing()<< endl;
}
* reader function:-
SeriesReaderType::Pointer READ_DCM (std::string InputFolder)
{
SeriesReaderType::Pointer seriesReader = SeriesReaderType::New();
seriesReader->SetImageIO(itk::GDCMImageIO::New());
itk::GDCMSeriesFileNames::Pointer nameGenerator = itk::GDCMSeriesFileNames::New();
nameGenerator->SetUseSeriesDetails(true);
nameGenerator->SetDirectory(InputFolder);
std::string seriesID = nameGenerator->GetSeriesUIDs().begin()->c_str();
seriesReader->SetFileNames(nameGenerator->GetFileNames(seriesID));
seriesReader->Update();
return seriesReader;
}
* 1st series output in itk:-
* 1st series output in matlab:-
What's worng with my 'series reader' code ??
I followed the "reading part" in this example.
I have the same problem, i use following similar codes to read dicom series, but the output of spacing between slices is sometimes correct BUT not always:
// 1) Read the input series
typedef itk::GDCMImageIO ImageIOType;
typedef itk::GDCMSeriesFileNames InputNamesGeneratorType;
ImageIOType::Pointer gdcmIO = ImageIOType::New();
InputNamesGeneratorType::Pointer inputNames=InputNamesGeneratorType::New();
inputNames->SetInputDirectory( dirPath );
inputNames->AddSeriesRestriction("0020|0013");
// then i select a serie identifier and pass it to the reader
typedef itk::ImageSeriesReader< CTImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New(); ;
reader->SetImageIO( gdcmIO );
reader->SetFileNames( inputNames->GetFileNames( seriesIdentifier.c_str() ));
reader->UpdateOutputInformation();
--->>> reader->GetOutput()->GetSpacing()[2] is not correct always!!!
ITK/SimpleITK assume that when you provide a series of images the files are in the same order as the slices. For many collections this is not the case and you have to presort the files (more details for python here) based on the Slice Location tag (or .GetOrigin).

Error with Spine Atlas file

i'm using cocos2d-x 2.2.3 and spine 1.9.07.
I've exported "seller.atlas", "seller.json" and "seller.png" by Spine and put them in Resource folder of my project. Then, in init() method I add these code to use skeleton animation
skeletonNode = CCSkeletonAnimation::createWithFile("spine/seller.json", "spine/seller.atlas");
skeletonNode->debugSlots = true;
skeletonNode->timeScale = 0.5f;
skeletonNode->setAnimation("walk", true);
skeletonNode->debugBones = true;
CCSize windowSize = CCDirector::sharedDirector()->getWinSize();
skeletonNode->setPosition(ccp(windowSize.width / 2, 50));
addChild(skeletonNode);
but It throws out an error like this
void CCObject::release(void)
{
CCAssert(m_uReference > 0, "reference count should greater than 0");
--m_uReference;
if (m_uReference == 0)
{
delete this;
}
}
It means that skeletonNode is NULL so it must be something wrong with the atlas file.
But I don't know what wrong is it :(
Any help would be appreciated! :D
It's because cocos2dx 2.2.3 is using an old spine parser. Spine 1.9 generates atlas files in a different format. there is an extra line of "size: xxx,xxx".
To address this specific problem, add
readLine(0, end, &str);
in Atlas.cpp
before
if (!readValue(end, &str)) return abortAtlas(self);
Note you might run into other problems such as unknown attachment type mesh/skinned mesh since Spine 1.9 using new format. You need to update spine code in 2.2.3 to fix all.

How can I print the data contained by a C++ Map while debugging using DBX

I want to know the contents of a Map while debugging a c++ program.
I am using command line dbx.
I have pointer to the map.
Is there a way in which i can get the data printed.
--
Edit:
p *dataMap will give me this::
p *dataMap
*dataMap = {
__t = {
__buffer_size = 32U
__buffer_list = {
__data_ = 0x3ba2b8
}
__free_list = (nil)
__next_avail = 0x474660
__last = 0x474840
__header = 0x3b97b8
__node_count = 76U
__insert_always = false
__key_compare = {
/* try using "print -r" to see any inherited members */
}
}
}
Thanks
Alok Kr.
you need to write a ksh function to pretty print map, here is an example :
put following line in .dbxrc
source /ksh_STL_map
in dbx, use ppp to call ksh function that define in ksh_STL_map:
(dbx) ppp k
k = 2 elems {343, 0x301f8; 565, 0x30208}
I tried to post content of ksh_STL_map here, but this editor format will mess up the content, it's better that you post your email, then I can send ksh_STL_map directly to you.

Resources