关于string的一些操作,仅供自己阅读,之后修改

1.resnet的网络结构,caffe里面的各个功能模块

2.cuda文件的编写操作

#include "read_csv.h"
#include <string.h>
#include <iostream>
#include<stdio.h>
read_csv::read_csv()
{

}

read_csv::read_csv(std::string path,std::string camname,std::string gpsname,std::string imuname,std::string pcapname,std::string lidarbinpath)
{
        this->loadpath=path;
        std::string path1=path;
        std::string path2=path;
        std::string path3=path;
        std::string path4=path;
        this->camname=path1.append(camname);
        this->gpsname=path2.append(gpsname);
        this->imuname=path3.append(imuname);
        this->pcapname=path4.append(pcapname);
        this->lidarbinpath=lidarbinpath;
}
void read_csv::init(std::string path,std::string camname,std::string gpsname,std::string imuname,std::string pcapname,std::string lidarbinpath)
{
        this->loadpath=path;
        std::string path1=path;
        std::string path2=path;
        std::string path3=path;
        std::string path4=path;
        this->camname=path1.append(camname);
        this->gpsname=path2.append(gpsname);
        this->imuname=path3.append(imuname);
        this->pcapname=path4.append(pcapname);
        this->lidarbinpath=lidarbinpath;
}
void read_csv::GetcamwithoutTocken()
{
    std::ifstream file(this->camname.c_str());
    std::string s;
    std::string ss;
    getline(file,s);//skip the first line
    while(std::getline(file,s))
    {
          long time=atol(s.substr(0,8).c_str());
          s=s.substr(8,s.length());
          Encode_data enc;
          enc.timestamp=time;
          enc.res=s;
          Encode_cam_data.push_back(enc);
    }
}
void read_csv::GetgpswithoutTocken()
{
    std::ifstream file(this->gpsname.c_str());
    std::string s;
    std::string ss;
    getline(file,s);//skip the first line
    while(std::getline(file,s))
    {
          long time=atol(s.substr(0,8).c_str());
          s=s.substr(8,s.length());
          Encode_data enc;
          enc.timestamp=time;
          enc.res=s;
          Encode_gps_data.push_back(enc);
    }
}
void read_csv::GetimuwithoutTocken()
{
    std::ifstream file(this->imuname.c_str());
    std::string s;
    std::string ss;
    getline(file,s);//skip the first line
    while(std::getline(file,s))
    {
          long time=atol(s.substr(0,8).c_str());
          s=s.substr(8,s.length());
          Encode_data enc;
          enc.timestamp=time;
          enc.res=s;
          Encode_imu_data.push_back(enc);
    }
}


void read_csv::GetpcapwihoutTocken()
{
     Pcap pcap(this->pcapname);
     pcap.path=this->lidarbinpath;
     pcap.StartRun();
}




std::string read_csv::decoding(std::string res,int token)
{

        for(int i=0;i<res.length();i++)
        {

          // (token<5)?(res.c_str(i)=res.c_str(i)-token):(res.c_str(i)=res.c_str(i)+token);
        }
        return res;
}








void read_csv::getcam()
{
    std::ifstream file(this->camname.c_str());
    std::string s;
    std::string ss;
    getline(file,s);//skip the first line
    while(std::getline(file,s))
    {
        std::stringstream linearray(s);
        std::getline(linearray,ss,',');//timestamp
        long time=atol(ss.c_str());
        std::getline(linearray,ss);//filename
        char imagename[240];
        sprintf(imagename,"%s",ss.c_str());
        imagename[strlen(imagename)-1]=0;//去掉换行符号
        Cam_data cam;
        cam.timestamp=time;
        memcpy(cam.filename,imagename,sizeof(imagename));
        cam_data.push_back(cam);
    }
}

void read_csv::getgps()
{
    std::ifstream file(this->gpsname.c_str());
    std::string s;
    std::string ss;
    getline(file,s);//skip the first line
    while(std::getline(file,s))
    {
        std::stringstream linearray(s);
        std::getline(linearray,ss,',');//timestamp
        long timetemp=atol(ss.c_str());
        std::getline(linearray,ss,',');//latitude
        double lati=atof(ss.c_str());
        std::getline(linearray,ss,',');//longitude
        double longti=atof(ss.c_str());
        std::getline(linearray,ss,',');//altitude
        double altitude=atof(ss.c_str());
         std::getline(linearray,ss,',');//nsv1
        int nsv1=atoi(ss.c_str());
        std::getline(linearray,ss,',');//nsv2
        ss = ss.substr(0,ss.length() - 1);
         int nsv2=atoi(ss.c_str());
         GPS_data gps;
         gps.altitude=altitude;
         gps.latitude=lati;
         gps.longitude=longti;
         gps.NSV1=nsv1;
         gps.NSV2=nsv2;
         gps.timestamp=timetemp;
         gps_data.push_back(gps);

    }
}

void read_csv::getimu()
{
    std::ifstream file(this->imuname.c_str());
    std::string s;
    std::string ss;
    getline(file,s);//skip the first line
    while(std::getline(file,s))
    {
        std::stringstream linearray(s);
        std::getline(linearray,ss,',');//timestamp
        long timetemp=atol(ss.c_str());
        std::getline(linearray,ss,',');//heading
        double heading=atof(ss.c_str());
        std::getline(linearray,ss,',');//pitch
        double pitch=atof(ss.c_str());
        std::getline(linearray,ss,',');//roll
        ss=ss.substr(0,ss.length()-1);
        double roll=atof(ss.c_str());
         IMU_data imu;
         imu.timestamp=timetemp;
         imu.heading=heading;
         imu.pitch=pitch;
         imu.roll=roll;
         imu_data.push_back(imu);

    }
}

read_csv::~read_csv()
{

}

猜你喜欢

转载自blog.csdn.net/weixin_38907330/article/details/82053534