QT显示框架嵌入Vs控制台工程
生活随笔
收集整理的這篇文章主要介紹了
QT显示框架嵌入Vs控制台工程
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
? 一、一些準(zhǔn)備工作:
?????????
1.安裝Qt for VS 的插件;
??????? 安裝Qt for VS 的插件
??????? 下載地址:http://download.qt.io/official_releases/vsaddin/
??????? 安裝Qt 4.8.6
??????? 下載地址:http://download.qt.io/official_releases/qt/4.8/4.8.6/qt-opensource-windows-x86-vs2010-4.8.6.exe.mirrorlist
?2.進(jìn)行一些設(shè)置:
??????? 找到菜單項(xiàng):
??????? Qt——> Qt Option——> 選取版本 ??
——>? ——>
在工程選項(xiàng)中添加必須的包含文件和lib文件
然后可以使用Qt
二、工程和代碼:
Vs控制臺(tái)工程可以直接使用Qt的顯示框架,使用類似于Qt-IDE的主函數(shù)代碼:
int _tmain(int argc, char* argv[]) {QApplication a(argc, argv);CPlot *objViewer = new CPlot();objViewer->show();return a.exec(); }
頭文件代碼:
#pragma once /* */#include <QApplication> #include <QMainWindow> #include <QWidget> #include <QAction> #include <QMenu> #include <QToolBar> #include <QGLWidget>#include <gl/glut.h>#include <QMainWindow> #include <QWidget> #include <QAction> #include <QMenu> #include <QToolBar> #include "OpenGLViewer.h"class QApplication; class QMainWindow; class QWidget; class QAction; class QMenu; class QToolBar;class CPlot: public QMainWindow{Q_OBJECTpublic:CPlot(QWidget *parent = 0);//CPlot();~CPlot(void);//測(cè)試OpenGL畫圖 public:static void RenderScene();void SetupRC();static void ChangeSize( GLsizei w, GLsizei h );void drawCircle(int argc, char *argv[]);GLfloat boundingRadius;GLfloat LightDistanceRatio;GLfloat rotationX;GLfloat rotationY;GLfloat rotationZ;GLfloat xscale;GLfloat yscale;GLfloat zscale;GLfloat transX;GLfloat transY;GLfloat transZ;void draw3dAxis();void draw3dAxis(int argc, char *argv[]);void updatePos(const Mat &rMat);private:CEkfSlam m_Slamer;private slots:void openFile();//void closeFile();void segmentObj();void capture();private:OpenGLViewer *openglViewer;private:void initializeGL();void setMaterial();void GLMaterial(const OpenGL::Material& material);void setLight();void setAntiAliasing();float getBoundingRadius();void setTexture(IplImage* img);void loadTexture();void resetGLLightPosition();void loadMeshFile(char* filename);void createActions();void createMenus();void createToolBars();private:QAction *loadFileAction;QAction *closeFileAction;QAction *segmentObjAction;QAction *captureAction;QMenu *fileMenu;QMenu *toolMenu;QToolBar *fileToolBar;QToolBar *toolsBar;vector<int> faceColors;vector<QColor> FaceColorList;vector<double>ssdf;QPoint lastPos;Core::Geometry::MyMesh *mesh;int key_type;GLuint texName;Mat textImage;public://1.使用 OpenCV Mat畫圖!用于顯示圖像和特征點(diǎn)匹配!cv::Mat m_Canvas;cv::Mat m_CanvasSrc; private://2.使用 VTK畫出點(diǎn)云!用于顯示地圖和方位演化!Eigen::MatrixXf m_FeatureMap;//畫出十字光標(biāo)int cvDrawCrossCursor(cv::Mat &Canvas,cv::Point &PointS,cv::Point &PointE,cv::Scalar &Color,int Width,int CV_A_Type,int Mark);//畫十字光標(biāo),中心點(diǎn)、線長(zhǎng)度、色彩、線寬int cvDrawCrossCursor(cv::Mat &Canvas,cv::Point &Center,int Length,cv::Scalar &Color,int Width,int CV_A_Type,int Mark);};源碼文件代碼: #include "StdAfx.h" #include "Plot.h"#include <iostream> #include <iomanip> #include <fstream> #include <QApplication> #include <QFileDialog> #include <QString> #include <QMenuBar> #include <QDesktopWidget> #include <opencv/cv.h> #include <opencv/highgui.h> #include <vector>class QFileDialog; class QString; class QMenuBar; class QDesktopWidget;using namespace Qt; using namespace OpenGL;此種用法是錯(cuò)誤的,使用mainwindow之前必須構(gòu)建一個(gè)Application! CPlot::CPlot(QWidget *parent) : QMainWindow(parent){openglViewer = new OpenGLViewer();this->setCentralWidget(openglViewer);this->setWindowTitle("Wishchin's PCL Window");this->setGeometry((QApplication::desktop()->width()-1.5 *QApplication::desktop()->height())/2,20,640,480);this->createActions();this->createMenus();this->createToolBars();//初始化畫布this->m_Canvas.create(640,480,CV_8UC3);this->m_CanvasSrc.create(640,480,CV_8UC3);//this->m_FeatureMap.resize(0); }//CPlot::CPlot(){ // //初始化畫布 // this->m_Canvas.create(640,480,CV_8UC3); // // //this->m_FeatureMap.resize(0); //}CPlot::~CPlot(void) { }void CPlotMark0022(){}//畫出十字光標(biāo) int CPlot::cvDrawCrossCursor(cv::Mat &Canvas,cv::Point &PointS,cv::Point &PointE,cv::Scalar &Color,int Width,int CV_A_Type,int Mark) {return 1; }//畫十字光標(biāo),中心點(diǎn)、線長(zhǎng)度、色彩、線寬 int CPlot::cvDrawCrossCursor(cv::Mat &Canvas,cv::Point &Center,int Length,cv::Scalar &Color,int Width,int CV_A_Type,int Mark) {int H = Length/2;cv::Point PointS;cv::Point PointE;PointS.x =Center.x ;PointS.y =Center.y -H;PointE.x =Center.x ;PointE.y =Center.y +H;cv::line(this->m_Canvas,PointS,PointE,Color,Width,CV_A_Type,Mark);PointS.x =Center.x -H;PointS.y =Center.y;PointE.x =Center.x +H;PointE.y =Center.y;cv::line(this->m_Canvas,PointS,PointE,Color,Width,CV_A_Type,Mark);return 1; }void CPlotMark003(){}void CPlot::draw3dAxis(int argc, char *argv[]) {Mat rMat(1,3,CV_32F);rMat.at<float>(0,0) = 1;if (1<0)rMat.at<float>(0,1) = 1;elserMat.at<float>(0,1) = 1;if(1<0)rMat.at<float>(0,2) = 1;elserMat.at<float>(0,2) = 1;this->updatePos(rMat);openglViewer->updateGL();return; }void CPlot::updatePos(const Mat& rMat) {Mat rrMat;rMat.convertTo(rrMat , CV_32F);//rMat.convertTo(rMat , CV_32F);rotationX = rrMat.at<float>(0,0); rotationY = rrMat.at<float>(0,1);rotationZ = rrMat.at<float>(0,2); }void CPlot::draw3dAxis() {GLfloat x = GLfloat(640) / 480;glMatrixMode(GL_MODELVIEW); glLoadIdentity();gluLookAt(-2.0 , 6.0, -4.0, 0.0 , 0.0 , 0.0 , 0.0, 1.0 , 0.0);float len = 0.2;//The world axis /coordinate system!//1. Line!glColor3f(0.0f,0.0f,1.0f); glBegin(GL_LINES); glVertex3f(-2.0f,00.0f,0.0f);//X line!glVertex3f(2.0f,0.0f,0.0f); glVertex3f(0.0f,-2.0f,0.0f); //Y line! glVertex3f(0.0f,2.0f,0.0f); glVertex3f(0.0f,0.0f,-2.0f); //Z line! glVertex3f(0.0f,0.0f,2.0f); glEnd(); //The world axis /coordinate system!//2. arrows!glColor3f(1.0f,0.0f,0.0f); // x arrows glPushMatrix(); glTranslatef(2.0f,0.0f,0.0f); glRotatef(90.0f,0.0f,1.0f,0.0f); glutSolidCone(0.1,0.3,10,10); glTranslatef(0.0f,0.0f,0.4f); glBegin(GL_LINES); glVertex3f(-len,len,0.0f); glVertex3f(len,-len,0.0f); glEnd(); glBegin(GL_LINES); glVertex3f(len,len,0.0f); glVertex3f(-len,-len,0.0f); glEnd(); glPopMatrix(); glColor3f(0.0f,1.0f,0.0f); // y arrows glPushMatrix(); glTranslatef(0.0f,2.0f,0.0f); glRotatef(-90.0f,1.0f,0.0f,0.0f); glutSolidCone(0.1,0.3,10,10); glTranslatef(0.0f,0.0f,0.4f); glBegin(GL_LINES); glVertex3f(-len,len,0.0f); glVertex3f(0,0,0.0f); glEnd(); glBegin(GL_LINES); glVertex3f(len,len,0.0f); glVertex3f(0,0,0.0f); glEnd(); glBegin(GL_LINES); glVertex3f(0,-len,0.0f); glVertex3f(0,0,0.0f); glEnd(); glPopMatrix(); glColor3f(0.0f,0.0f,1.0f); // z arrowsglPushMatrix(); glTranslatef(0.0f,0.0f,2.0f); glRotatef(90.0f,0.0f,0.0f,1.0f); glutSolidCone(0.1,0.3,10,10); glTranslatef(0.0f,0.0f,0.4); glTranslatef(0.0f,0.0f,0.4f); glBegin(GL_LINES); glVertex3f(-len,len,0.0f); glVertex3f(len,len,0.0f); glEnd(); glBegin(GL_LINES); glVertex3f(len,len,0.0f); glVertex3f(-len,-len,0.0f); glEnd(); glBegin(GL_LINES); glVertex3f(-len,-len,0.0f); glVertex3f(len,-len,0.0f); glEnd(); glPopMatrix(); glTranslatef(transX,transY,-transZ);glRotatef(rotationX , 1.0,0.0,0.0);glRotatef(rotationY , 0.0,1.0,0.0);glRotatef(rotationZ , 0.0,0.0,1.0);glScalef(xscale, yscale, zscale);//The Cube aixs / coordinate system!//1. The axis line! glColor3f(1.0f,1.0f,1.0f); glBegin(GL_LINES); glVertex3f(-1.2f,00.0f,0.0f); glVertex3f(1.2f,0.0f,0.0f); glVertex3f(0.0f,-1.2f,0.0f); glVertex3f(0.0f,1.2f,0.0f); glVertex3f(0.0f,0.0f,-1.2f); glVertex3f(0.0f,0.0f,1.2f); glEnd(); //The Cube aixs / coordinate system!//2. The axis arrow!glColor3f(1.0f,0.0f,0.0f); //x arrowglPushMatrix(); glTranslatef(1.2f,0.0f,0.0f); glRotatef(90.0f,0.0f,1.0f,0.0f); glutSolidCone(0.05,0.15,10,10); glPopMatrix(); glColor3f(0.0f,1.0f,0.0f); // y glPushMatrix(); glTranslatef(0.0f,1.2f,0.0f); glRotatef(-90.0f,1.0f,0.0f,0.0f); glutSolidCone(0.05,0.15,10,10); glPopMatrix(); glColor3f(0.0f,0.0f,1.0f); // z glPushMatrix(); glTranslatef(0.0f,0.0f,1.2f); glRotatef(90.0f,0.0f,0.0f,1.0f); glutSolidCone(0.05,0.15,10,10); glPopMatrix(); The Cube Model//for(int i=0;i<mesh->getFCount();i++){// glLoadName(i);// glBegin(GL_TRIANGLES);// double r,g,b;// FaceColorList[1].getRgbF(&r,&g,&b);// glColor3d(r,g,b);// for(int j=0;j<3;j++){// MyPoint_ p = mesh->getPoint(mesh->getFace(i).getRef(j));// glNormal3d(p.GetNormal()[0],p.GetNormal()[1],p.GetNormal()[2]);// glVertex3f(p.GetPoint()[0], p.GetPoint()[1], p.GetPoint()[2]);// }// glEnd();//}//glFlush();} //測(cè)試使用OpenGL畫圓! void CPlot::drawCircle(int argc, char *argv[]) {glutInit(&argc, argv);glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);glutInitWindowSize (400, 300);glutInitWindowPosition (100, 100);glutCreateWindow( "Point examples" );glutDisplayFunc( this->RenderScene );glutReshapeFunc( this->ChangeSize );SetupRC();glutMainLoop();return ; } void CPlot::RenderScene() {//清空顏色緩沖區(qū),填充的顏色由 glClearColor( 0, 0.0, 0.0, 1 ); 指定為黑色glClear( GL_COLOR_BUFFER_BIT );//繪制一個(gè)點(diǎn){glColor3f( 1.0f, 0.0f, 0.0f );//指定點(diǎn)的顏色,紅色glPointSize( 9 );//指定點(diǎn)的大小,9個(gè)像素單位glBegin( GL_POINTS );//開始畫點(diǎn){glVertex3f(0.0f, 0.0f, 0.0f); // 在坐標(biāo)為(0,0,0)的地方繪制了一個(gè)點(diǎn)}glEnd();//結(jié)束畫點(diǎn)}//繪制一個(gè)點(diǎn)圓{glColor3f( 0.0f, 1.0f, 0.0f );//指定點(diǎn)的顏色,綠色glPointSize( 3 );//指定點(diǎn)的大小,3個(gè)像素單位glBegin( GL_POINTS );{ #define PI 3.14159f #define RADIUS 50.fGLfloat x = 0, y = 0, angle = 0.0;for ( angle = 0; angle <= 2.0f * PI; angle += 0.1f ){x = RADIUS * sin( angle );y = RADIUS * cos( angle );glVertex3f( x, y, 0 );}}glEnd();}//繪制x、y坐標(biāo)軸{glColor3f( 0.0f, 0.0f, 1.0f );//指定線的顏色,藍(lán)色glBegin( GL_LINES );{// x-axisglVertex3f( -100.0f, 0.0f, 0.0f);glVertex3f( 100.0f, 0.0f, 0.0f);// x-axis arrowglVertex3f( 100.0f, 0.0f, 0.0f);glVertex3f( 93.0f, 3.0f, 0.0f);glVertex3f( 100.0f, 0.0f, 0.0f);glVertex3f( 93.0f,-3.0f, 0.0f);// y-axisglVertex3f( 0.0f, -100.0f, 0.0f);glVertex3f( 0.0f, 100.0f, 0.0f);glVertex3f( 0.0f, 100.0f, 0.0f);glVertex3f( 3.0f, 93.0f, 0.0f);glVertex3f( 0.0f, 100.0f, 0.0f);glVertex3f( -3.0f, 93.0f, 0.0f);}glEnd();}glutSwapBuffers(); }void CPlot::SetupRC() {glClearColor( 0, 0.0, 0.0, 1 );glColor3f( 1.0f, 0.0f, 0.0f ); }void CPlot::ChangeSize( GLsizei w, GLsizei h ) {GLfloat nRange = 100.0f;// Prevent a divide by zeroif(h == 0)h = 1;// Set Viewport to window dimensionsglViewport(0, 0, w, h);// Reset projection matrix stackglMatrixMode(GL_PROJECTION);glLoadIdentity();// Establish clipping volume (left, right, bottom, top, near, far)if (w <= h)glOrtho (-nRange, nRange, -nRange*h/w, nRange*h/w, -nRange, nRange);elseglOrtho (-nRange*w/h, nRange*w/h, -nRange, nRange, -nRange, nRange);// Reset Model view matrix stackglMatrixMode(GL_MODELVIEW);glLoadIdentity(); }void CPlotMark004(){}void CPlot::initializeGL() {//loadTexture();loadMeshFile("cub.off");//loadMeshFile("sword.off");////qglClearColor(QColor(204,204,204)/*Qt::white*/);//暫時(shí)注銷,wishchin!!!glShadeModel(GL_SMOOTH);glClearDepth(1.0f);glEnable(GL_DEPTH_TEST);glEnable(GL_NORMALIZE);glLineWidth(1.5);//glColor3d(100,100,100);setMaterial();setLight(); } void CPlot::setLight() {GLfloat light_ambient[] = {0.0f, 0.0f, 0.0f, 1.0f};GLfloat light_diffuse[] = {1.0f, 1.0f, 1.0f, 1.0f};GLfloat light_specular[]= {1.0f, 1.0f, 1.0f, 1.0f};glLightfv( GL_LIGHT0, GL_AMBIENT, light_ambient);glLightfv( GL_LIGHT0, GL_DIFFUSE, light_diffuse);glLightfv( GL_LIGHT0, GL_SPECULAR, light_specular);glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);//glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL , GL_RGB);//glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL , GL_SEPARATE_SPECULAR_COLOR);glEnable(GL_LIGHTING);glEnable(GL_LIGHT0);resetGLLightPosition(); }void CPlot::setMaterial() {glEnable(GL_COLOR_MATERIAL);GLMaterial(OpenGL::Material::GetMaterial(OpenGL::Material::Default)); } void CPlot::GLMaterial(const OpenGL::Material& material) { glMaterialfv(GL_FRONT, GL_DIFFUSE, material.diffuse);glMaterialfv(GL_FRONT, GL_SPECULAR, material.specular);glMaterialfv(GL_FRONT, GL_AMBIENT, material.ambient);glMaterialf(GL_FRONT, GL_SHININESS, material.shininess);glMaterialfv(GL_BACK, GL_DIFFUSE, material.diffuse);glMaterialfv(GL_BACK, GL_SPECULAR, material.specular);glMaterialfv(GL_BACK, GL_AMBIENT, material.ambient);glMaterialf(GL_BACK, GL_SHININESS, material.shininess); } void CPlot::setAntiAliasing() {glEnable ( GL_POLYGON_SMOOTH );glEnable( GL_LINE_SMOOTH );glEnable ( GL_POINT_SMOOTH );glEnable(GL_BLEND);glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST );glHint(GL_LINE_SMOOTH_HINT, GL_NICEST );glHint(GL_POINT_SMOOTH_HINT, GL_NICEST );glEnable(GL_COLOR_MATERIAL); }void CPlot::setTexture(IplImage* img){glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glGenTextures(1, &texName); glBindTexture(GL_TEXTURE_2D, texName); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, img->width, img->height, 0, GL_RGB, GL_UNSIGNED_BYTE, img->imageData);glEnable(GL_TEXTURE_2D); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); glBindTexture(GL_TEXTURE_2D, texName); }void CPlot::resetGLLightPosition() {boundingRadius = getBoundingRadius();GLfloat light_position[] = {0.0f, 0.0, (float)(LightDistanceRatio*boundingRadius) , 1.0f};glLightfv(GL_LIGHT0, GL_POSITION, light_position); } float CPlot::getBoundingRadius() {//if (meshes.size() == 0) return 0;Core::Geometry::Vector3D pmin, pmax;//auto it = meshes.begin();//do {// MyMesh* last = *it;BoundingBox box = mesh->calBoundBox();// if (it == meshes.begin()) {// pmin = box.min;// pmax = box.max;// } else {// pmin = min(pmin, box.min);// pmax = max(pmax, box.max);// }// } while ((++it) != meshes.end());pmax = box.max ; pmin = box.min;return sqrt(pow(pmax[0] - pmin[0],2)+pow(pmax[1] - pmin[1],2)+pow(pmax[2] - pmin[2],2)); } void CPlot::loadMeshFile(char* filename) {xscale = 1.0; yscale = 1.0; zscale = 1.0;transX = 0.0; transY = 0.0;faceColors.clear();mesh->LoadFromFile(filename);mesh->calFaceNormal();mesh->calVertexNormal();int fCount = mesh->getFCount();char buf[255];sprintf(buf, "%s", filename);int len = strlen(buf);buf[len-1] = 'f'; buf[len-2] = 'd'; buf[len-3] = 's';FILE *fp = NULL; }void CPlotMark005(){}//初始化坐標(biāo)系,畫出世界坐標(biāo)系、標(biāo)志BOX、Box坐標(biāo)系! void CPlot::createActions(){loadFileAction = new QAction(tr("&Load"), this);closeFileAction = new QAction(tr("&Close"), this);segmentObjAction = new QAction(tr("&Segment"), this);captureAction = new QAction(tr("Capture") , this);connect(loadFileAction, SIGNAL(triggered()), this, SLOT(openFile()));connect(closeFileAction, SIGNAL(triggered()), this, SLOT(close()));connect(segmentObjAction, SIGNAL(triggered()), this, SLOT(segmentObj()));connect(captureAction, SIGNAL(triggered()), this, SLOT(capture())); }void CPlot::createMenus(){fileMenu = menuBar()->addMenu(tr("&File"));fileMenu->addAction(loadFileAction);fileMenu->addAction(closeFileAction);fileMenu->addAction(captureAction);toolMenu = menuBar()->addMenu(tr("&Tool"));toolMenu->addAction(segmentObjAction);toolMenu->addAction(captureAction); }void CPlot::createToolBars(){fileToolBar = addToolBar(tr("&File"));fileToolBar->addAction(loadFileAction);fileToolBar->addAction(closeFileAction);toolsBar = addToolBar(tr("Tool"));toolsBar->addAction(segmentObjAction); }void CPlot::openFile() {QString filename = QFileDialog::getOpenFileName(this, tr("Load a Shape"), ".", tr("Object Model (*.obj *.off)"));this->openglViewer->loadMeshFile(filename.toLatin1().data());this->openglViewer->updateGL(); }void CPlot::segmentObj(){}//進(jìn)行數(shù)據(jù)讀入 void CPlot::capture(){//// Do what you want// example// you can call openglViewer->updatePos(const Mat& rMat) function to show your Sensorfunsion// result, note that once you call this function, you can just call openglViewer->updateGL()// the re-paint the GL// like:char buffer[255];//ifstream pfile("/home/hll260/aiglass/proj/firefly-3288/1.txt");fstream pfile;pfile.open("D://SensorFusionVector//1030.txt");fstream outfile,outfile2;outfile.open("D://SensorFusionVector//2.txt");outfile2.open("D://SensorFusionVector//1103.txt");if(!pfile){ printf("Can not open file!!"); _exit(1);}long long sp = pfile.tellg();while(sp <= 207){pfile.seekg(0,ios::end);sp = pfile.tellg();cout << sp << endl;}float ax,ay,az,gx,gy,gz;char testgy[10];char *gyy="Gyro";char testac[10];char *acc="Acce";SensorFusion sf;int bbbb=1;vector <float> gyro(3,0);vector <float> accel(3,0);long long lastsp=0;pfile.seekg(lastsp);for(int i=1;i<=10;i++){pfile.getline(buffer,100);}lastsp = pfile.tellg();char buffer1[50];char buffer2[50];long linep=0;while (1)//!pfile.eof(){pfile.seekg(0,ios::end);pfile.clear();sp = pfile.tellg();if (linep==0)pfile.seekg(lastsp);elsepfile.seekg(linep);//cout <<sp<<" "<<lastsp<<endl;if (sp>lastsp){lastsp=sp;while(linep+144<sp){pfile.getline(buffer1,40);sscanf (buffer1,"%4s,%f,%f,%f",testac,&ax,&ay,&az);pfile.getline(buffer2,40);sscanf (buffer2,"%4s,%f,%f,%f",testgy,&gx,&gy,&gz);linep = pfile.tellg();if(strcmp(testac, acc) == 0&&strcmp(testac, testgy) == 0){pfile.getline(buffer2,40);sscanf (buffer2,"%4s,%f,%f,%f",testgy,&gx,&gy,&gz);linep = pfile.tellg();if(strcmp(testac, acc) == 0){accel.push_back(ax);accel.push_back(ay);accel.push_back(az);for (int i=0;i<3;i++){accel.erase(accel.begin());}}if (strcmp(testgy, gyy) == 0){ gyro.push_back(gx);gyro.push_back(gy);gyro.push_back(gz);for (int i=0;i<3;i++){gyro.erase(gyro.begin());}}}else{if(strcmp(testac, acc) == 0){accel.push_back(ax);accel.push_back(ay);accel.push_back(az);for (int i=0;i<3;i++){accel.erase(accel.begin());}}if (strcmp(testgy, gyy) == 0){ gyro.push_back(gx);gyro.push_back(gy);gyro.push_back(gz);for (int i=0;i<3;i++){gyro.erase(gyro.begin());}}}sf.SensorPretreatment(gyro);sf.handlemessage(accel,gyro,0.001);Mat rMat(1,3,CV_32F);//弧度 轉(zhuǎn)角度rMat.at<float>(0,0) = -sf.jiaodu[1]*57.3;if (sf.jiaodu[0]<0)rMat.at<float>(0,1) = 360-sf.jiaodu[0]*57.3;elserMat.at<float>(0,1) = sf.jiaodu[0]*57.3;if(sf.jiaodu[2]<0)rMat.at<float>(0,2) = sf.jiaodu[2]*57.3;elserMat.at<float>(0,2) = sf.jiaodu[2]*57.3;//傳入三維坐標(biāo)參數(shù)為絕對(duì)位置(相對(duì)于原點(diǎn))rMat.at<float>(0,3) = sf.LocX;rMat.at<float>(0,4) = sf.LocY;rMat.at<float>(0,5) = sf.LocZ;openglViewer->updatePos(rMat);openglViewer->updateGL();outfile<<sf.jiaodu[0]*57.3<<" "<<sf.jiaodu[1]*57.3<<" "<<sf.jiaodu[2]*57.3<<endl;cout<<sf.jiaodu[0]*57.3<<" "<<sf.jiaodu[1]*57.3<<" "<<sf.jiaodu[2]*57.3<<" "<<gyro.size()<<endl;outfile2<<double(accel[0])<<" "<<double(accel[1])<<" "<<double(accel[2])<<endl;outfile2<<double(gyro[0])<<" "<<double(gyro[1])<<" "<<double(gyro[2])<<endl;outfile2<<"sp:"<<sp<<" linep:"<<linep<<endl;}}else{ continue;}}outfile.close();outfile2.close();pfile.close();}
還有一些其他的程序段,等整理好之后再進(jìn)行上傳....................
總結(jié)
以上是生活随笔為你收集整理的QT显示框架嵌入Vs控制台工程的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: SLAM: Orb_SLAM的使用小综述
- 下一篇: 如何拍摄中焦星空人像?Z8 样图幕后揭秘