When importing a ply-file into my program I get an Error-message saying that something went wrong with the following message:
C:\Users\...\data\apple.ply:8: property 'list uint8 int32 vertex_indices' of element 'face' is not handled
I used a sample ply file from: https://people.sc.fsu.edu/~jburkardt/data/ply/apple.ply
I have already tried different ply files from different sources but none of them work. When debugging the program the io::loadPLYFile doesn't generate a valid pointcloud. Runtime Library for PCL and for my program are the same.
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/io/ply_io.h>
#include <pcl/point_types.h>
#include <pcl/search/kdtree.h>
#include <pcl/features/normal_3d_omp.h>
#include <pcl/surface/marching_cubes_rbf.h>
using namespace pcl;
using namespace std;
int
main (int argc, char** argv)
{
PointCloud<PointXYZ>::Ptr cloud (new PointCloud<PointXYZ>);
std::cout << "Start Debug?" << std::endl;
std::cin.ignore();
if(io::loadPLYFile<PointXYZ> (argv[1], *cloud) == -1){
cout << "ERROR: couldn't find file" << endl;
return (1);
} else {
cout << "loaded" << endl;
NormalEstimationOMP<PointXYZ, Normal> ne;
search::KdTree<PointXYZ>::Ptr tree1 (new search::KdTree<PointXYZ>);
tree1->setInputCloud (cloud);
ne.setInputCloud (cloud);
ne.setSearchMethod (tree1);
ne.setKSearch (20);
PointCloud<Normal>::Ptr normals (new PointCloud<Normal>);
ne.compute (*normals);
I would expect the PCL function io::loadPLYFile to load the files properly as described in the documentation http://docs.pointclouds.org/1.3.1/group__io.html
the console output is just a warning as #kanstar already suggested! It can easily be ignored. The reason my program crashed in Debug but not in Release was that my Visual Studio linked to the wrong library version of boost which resulted in the crash. Fixing the linkage made the pcl::NormalEstimationOMP work as expected.
Related
I'm trying to configure eclipse cdt to compile code that contains the mongocxx driver. This code is from mongo's installation page. The same errors I am getting on my own project are clearly displayed here. The includes are recognized but I believe that it is a linker issue.
#include <iostream>
#include <bsoncxx/builder/stream/document.hpp>
#include <bsoncxx/json.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>
int main(int, char**) {
mongocxx::instance inst{};
mongocxx::client conn{mongocxx::uri{}};
bsoncxx::builder::stream::document document{};
auto collection = conn["testdb"]["testcollection"];
document << "hello" << "world";
collection.insert_one(document.view());
auto cursor = collection.find({});
for (auto&& doc : cursor) {
std::cout << bsoncxx::to_json(doc) << std::endl;
}
}
This is my actual screenshot with errors from my IDE
I'm trying to write a simple SIP sniffer using libtins which works nice.
I then try to parse the packet received to libosip.
Although it does parses the message properly, it dies silently.
I've no idea what could be wrong here, some help would be greatly appreciated!
this is my source:
#include <iostream>
#include "tins/tins.h"
#include <osip2/osip.h>
#include <osipparser2/osip_message.h>
#include <vector>
using namespace Tins;
bool invalidChar (char c);
void stripUnicode(std::string & str);
bool callback(const PDU &pdu)
{
const IP &ip = pdu.rfind_pdu<IP>(); // Find the IP layer
const UDP &udp = pdu.rfind_pdu<UDP>(); // Find the TCP layer
osip_message *sip;
osip_message_init(&sip);
// First here we print Source and Destination Information
std::cout << ip.src_addr() << ':' << udp.sport() << " -> "
<< ip.dst_addr() << ':' << udp.dport() << std::endl;
// Extract the RawPDU object.
const RawPDU& raw = udp.rfind_pdu<RawPDU>();
// Finally, take the payload (this is a vector<uint8_t>)
const RawPDU::payload_type& payload = raw.payload();
// We create a string message
std::string message( payload.begin(), payload.end() );
std::string sip_message;
// Try to parse the message
std::cout << "copying message with len " << message.size() << std::endl;
const char *msg = message.c_str();
std::cout << "parsing message with size " << strlen(msg) << std::endl;
osip_message_parse( sip, msg, strlen( msg ) );
std::cout << "freeing message" << std::endl;
osip_message_free(sip);
return true;
}
int main(int argc, char *argv[])
{
if(argc != 2) {
std::cout << "Usage: " << *argv << " <interface>" << std::endl;
return 1;
}
// Sniff on the provided interface in promiscuos mode
Sniffer sniffer(argv[1], Sniffer::PROMISC);
// Only capture udp packets sent to port 53
sniffer.set_filter("port 5060");
// Start the capture
sniffer.sniff_loop(callback);
}
The output is this:
1.2.3.4:5060 -> 4.3.2.1:5060
copying message with len 333
parsing message with size 333
And it dies silently.
If I remove the line:
osip_message_parse( sip, msg, strlen( msg ) );
It keeps going perfectly...
Thanks a lot for your help!
I finally found the problem.
it is necessary to initialise the parser with
parser_init();
It's not documented anywhere :(
Now it's not dying on me anymore, but the parsing is not working properly. I need to investigate more.
Thanks everyone!
David
First, if a memory corruption happens before, the crash may happen in osip_message_parse but this might not be the origin of the initial corruption.
In order to test a sip message with libosip, you can go into the build directory of osip and create a file containing your sip message: mymessage.txt
$> ./src/test/torture_test mymessage.txt 0 -v
and even for a deeper check with valgrind:
$> valgrind ./src/test/.libs/torture_test mymessage.txt 0 -v
If your code is failing for all sip message, I guess the issue is a memory corruption outside libosip.
You do have another bug with the size of the SIP message:
osip_message_parse( sip, msg, strlen( msg ) );
A SIP message can contain binary data with \0 char inside, so your code should use the exact length of binary payload not strlen(). Such a change is required (but won't fix your main issue):
osip_message_parse( sip, msg, payload.end() - payload.begin() );
I also advise you to try the latest osip git and complete your question with a copy of a SIP message failing.
EDIT: As David found, the init wasn't done and that was the origin of the issue. However, the correct way to init is as specified by first line of documentation:
How-To initialize libosip2
When using osip, your first task is to initialize the parser and the state machine. This must be done prior to any use of libosip2.
#include <sys/time.h>
#include <osip2/osip.h>
int i;
osip_t *osip;
i=osip_init(&osip);
if (i!=0)
return -1;
Maybe a stupid question but I like to decode these kind of unicode characters. How do I do it?
۫ͫ̈́̊̃͛͐̎̂̓̃̇͛̍ͪͩ́͒͆̓̉̽̍̏͂ͮ̈́ͦ̀ͤ͗̅͗̄̐̃ͬͮͣͩͮ̆̓́͛ͯͤͣͧ̔ͮ̈́ͯ̅۫ͫ̈́̊̃͛͐̎̂̓̃̇͛̍ͪͩ́͒͆̓̉̽̍̏͂ͮ̈́ͦ̀ͤ͗̅͗̄̐̃ͬͮͣͩͮ̆̓́͛ͯͤͣͧ̔ͮ̈́ͯ̅۫ͫ̈́̊̃͛͐̎̂̓̃̇͛̍ͪͩ́͒͆̓̉̽̍̏͂ͮ̈́ͦ̀ͤ͗̅͗̄̐̃ͬͮͣͩͮ̆̓́͛ͯͤͣͧ̔ͮ̈́ͯ̅۫ͫ̈́̊̃͛͐̎̂̓̃̇͛̍ͪͩ́͒͆̓̉̽̍̏͂ͮ̈́ͦ̀ͤ͗̅͗̄̐̃ͬͮͣͩͮ̆̓́͛ͯͤͣͧ̔ͮ̈́ͯ̅۫ͫ̈́̊̃͛͐̎̂̓̃̇̚̚̚̚̚̚̚̚̚̚̚̚
۫ͫ̈́̊̃͛͐̎̂̓̃̇͛̍ͪͩ́͒͆̓̉̽̍̏͂ͮ̈́ͦ̀ͤ͗̅͗̄̐̃ͬͮͣͩͮ̆̓́͛ͯͤͣͧ̔ͮ̈́ͯ̅۫ͫ̈́̊̃͛͐̎̂̓̃̇͛̍ͪͩ́͒͆̓̉̽̍̏͂ͮ̈́ͦ̀ͤ͗̅͗̄̐̃ͬͮͣͩͮ̆̓́͛ͯͤͣͧ̔ͮ̈́ͯ̅۫ͫ̈́̊̃͛͐̎̂̓̃̇͛̍ͪͩ́͒͆̓̉̽̍̏͂ͮ̈́ͦ̀ͤ͗̅͗̄̐̃ͬͮͣͩͮ̆̓́͛ͯͤͣͧ̔ͮ̈́ͯ̅۫ͫ̈́̊̃͛͐̎̂̓̃̇͛̍ͪͩ́͒͆̓̉̽̍̏͂ͮ̈́ͦ̀ͤ͗̅͗̄̐̃ͬͮͣͩͮ̆̓́͛ͯͤͣͧ̔ͮ̈́ͯ̅۫ͫ̈́̊̃͛͐̎̂̓̃̇̚̚̚̚̚̚̚̚̚̚̚̚
I like to be able to decode them into /uXXXX syntax so I can use them for instance in a web page...
If you're using windows you can try copying and pasting that into the character map application.
In C++ (with an implementation that supports C++11, such as is included in Xcode):
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdint>
int main() {
std::u32string s = U"ͫ̈́̊̃͛͐̎̂̓̃̇͛̍ͪͩ́͒͆̓̉̽̍̏͂ͮ̈́ͦ̀ͤ͗̅͗̄̐̃ͬͮͣͩͮ̆̓́͛ͯͤͣͧ̔ͮ̈́ͯ̅۫ͫ̈́̊̃͛͐̎̂̓̃̇͛̍ͪͩ́͒͆̓̉̽̍̏͂ͮ̈́ͦ̀ͤ͗̅͗̄̐̃ͬͮͣͩͮ̆̓́͛ͯͤͣͧ̔ͮ̈́ͯ̅۫ͫ̈́̊̃͛͐̎̂̓̃̇͛̍ͪͩ́͒͆̓̉̽̍̏͂ͮ̈́ͦ̀ͤ͗̅͗̄̐̃ͬͮͣͩͮ̆̓́͛ͯͤͣͧ̔ͮ̈́ͯ̅۫ͫ̈́̊̃͛͐̎̂̓̃̇͛̍ͪͩ́͒͆̓̉̽̍̏͂ͮ̈́ͦ̀ͤ͗̅͗̄̐̃ͬͮͣͩͮ̆̓́͛ͯͤͣͧ̔ͮ̈́ͯ̅۫ͫ̈́̊̃͛͐̎̂̓̃̇̚̚̚̚̚̚̚̚̚̚̚̚";
std::cout.fill('0');
std::cout << std::hex;
for (auto c : s)
std::cout << "\\u" << std::setw(4) << static_cast<std::uint_least32_t>(c);
}
I'm trying to pass arguments in XCode and understand you need to add them from the Args tab, using the Get Info button, in the Executables of the Groups and Files pane. I'm trying to see if I can get it to work, but am having some difficulty. My program is simply:
#include <iostream>
#include <ostream>
using namespace std;
int main(int argc, char *argv[]) {
for (int i = 0; i < argc; i++) {
cout << argv[i];
}
return 0;
}
And in the Args tab, I have the number 2 and then in another line the number 1. I do not get any output when I run the program. What am I doing wrong? Thanks!
Your code works fine and it displays the arguments.
You may want to print a new line after each argument to make the output more readable:
cout << argv[i] << "\n";
Output is visible in the console (use Command+Shift+R to bring up the console).
i have problem with libhid .
i found that there 2 way 4 accessing the usb-hid in linux
1)linux default libraries like input.h and hiddev.h and ...
2)using libhid
i found libhid some confusing and try to use input.h but i have problem with that 2.
i dont know how to get information about my device from ubuntu
i use open() to open the device
str="/dev/inpt/eventX" \\where X=0,1,...,7(I'm not sure about this)
open(str,O_RDWR)
then get info with ioctl
ioctl(fd,EVIOCGVERSION,&version);
but it give me wrong vendor and product IDs
then
i try to use libhid but had know idea how to use libhid (or any other library) in eclipse or netbeans
can you tell me how you compiled your codes any IDE like eclipse or netbeans or just using terminal and gcc?
or
how to work with ioctl() and open() ?
my whole example code:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ftw.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <asm/types.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/usbdevice_fs.h>
#include <linux/input.h>
#include <strings.h>
struct input_devinfo
{
uint16_t bustype;
uint16_t vendor;
uint16_t product;
uint16_t version;
};
int main(void) {
//puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */
//usb_device ud;
//int i=0;
//string str;
//str=char[100];
//str="/dev/input/event0\n";
printf("------------- start -----------------\n");
char str[]="" ;
int version=0;
char c[16];
char t;
int i,fd;
//for (i=0 ; i<8 ; i++)
{
//strcpy(c,str);
//t=i-'0';
//printf("salam5\n");
//c[15]=t;
//openning
//open(str,O_RDONLY);//read and write
if ((fd = open(str,O_RDWR)) < 0)
perror("str open\n");
else
printf("%s opened successfully\n",str);
ioctl(fd,EVIOCGVERSION,&version);
printf("version = %d \n",version);
printf("evdev driver version is %d.%d.%d\n",version >> 16, (version >> 8) & 0xff, version & 0xff);
//geting info from device
struct input_devinfo device_info;
ioctl(fd,EVIOCGID,&device_info);
printf("vendor 0x%04hx product 0x%04hx version 0x%04hx is on ?",
device_info.vendor, device_info.product,
device_info.version);
}
return EXIT_SUCCESS;
}
I find a way to compile my code in eclipse
1 problem solved
to compile your code with GCC in terminal you should define libhid for GCC by adding "-lhid" to your command :
gcc test_libhid.c -lhid
if your using eclipse and you want to use libhid with it you should add "-lhid" to gcc linker in order to gcc could use libhid when its compiling your code
follow the steps:
1)on the project Explorer panel , R-click on your project select properties (last option)
or select your project and press Alt+Enter
2)in the left panel expand "c/c++ build" and select "setting"
3)in the right side select "tool setting" tab
4)you should see GCC C compiler and GCC C linker and GCC assembler in there .
expand GCC C linker and select Libraries
5)after selecting in the right side you should see 2 boxes: Libraries(-l) and Library search path(-L)
in the Libraries(-l) add "hid"
note:eclipse use GCC to compile your codes when you do this steps eclipse add "-lhid" parameter to gcc to able it recognizing the libhid.