恩,我的版本使用如下:opencv2.0
libz: zlib-1.2.3
libjpeg: jpegsrc.v6b
libpng: libpng-1.2.18
libyasm: yasm-0.7.2
opencv: opencv-2.0.0
libx264: x264-snapshot-20110612-2245-stable
libxvid: xvidcore-1.3.2
ffmpeg: ffmpeg-0.5.3
听说GTK不好移植,所以我用QT来代替GTK部分!
以下是我的程序部分:
widget.cpp:
#include "widget.h"
#include "ui_widget.h"
#include <QPainter>
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
timer = new QTimer(this);
connect(timer,SIGNAL(timeout()),this,SLOT(slot_timer()));
timer->start(FPS);
capture=cvCreateCameraCapture(2);
}
Widget::~Widget()
{
delete ui;
cvReleaseImage(&frame);
}
void Widget::slot_timer()
{
frame=cvQueryFrame(capture);
if(!frame)
{
return;
}
cvCvtColor(frame,frame,CV_BGR2RGB);
img=new QImage((unsigned char*)frame->imageData,frame->width,frame->height,frame->widthStep,QImage::Format_RGB888);
update();
}
void Widget::paintEvent(QPaintEvent *event)
{
QPainter *pp=new QPainter(this);
pp->drawImage(0,0,*img);
}
widget.h:
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include "istream"
#include "stdio.h"
#include "highgui.h"
#include "cv.h"
#include <QTimer>
#include <QImage>
using namespace std;
#define TIME_LOCK 30
#define FPS 30
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
private:
Ui::Widget *ui;
IplImage *frame;
CvCapture *capture;
QTimer *timer;
QImage *img;
private slots:
void slot_timer();
protected:
void paintEvent(QPaintEvent *event);
};
#endif // WIDGET_H
main.cpp:
#include <QtGui/QApplication>
#include "widget.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();
return a.exec();
}
另外:我的QT都是使用tiny6410自带的,以上的库文件也是用友善tiny6410自带的4.5.1编译器交叉编译的!
另外我想问一下:那个技术手册上面关于setqt4env文件当中有一行内容如下:
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
我用友善自带的根文件系统usr/local下面没有lib目录,在usr下面有一个lib,是不是应该改为
export LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH