Linux environment: RedHat5 cross-Compilation: 4.1.2arm9-board: LT2440Opencv transplantation is applied to Qt kernel. The following is a migration process based on the online materials. During opencv transplantation, I will "optruanjianTrollt" under the same library
Linux environment: Red Hat 5 cross compilation: 4.1.2 arm9-board: LT2440 Opencv transplantation for Qt ------------------------------------- The following is a reference to the online materials combined with the actual transplantation process, during the opencv porting, I put all the required libraries under the same directory "/opt/ruanjian/Trollt
Linux: Red Hat 5
Cross-Compilation: 4.1.2
Arm9-board: LT2440
Application of Opencv to Qt
-----------------------------------
The following is a reference to the online migration process.
"/Opt/ruanjian/Trolltech/qt-4.6.3" under the same project ".
This process is because I have not been able to depend on ffmpeg and Opencv (but the related libraries of ffmpeg must be available. In this process, I put ffmpeg and Opencv in the same directory, but they cannot establish dependencies between them, however, dependencies can be created in different directories, but one problem is that the library required for porting is burned to the ARM board. when running the program, "libavformat" is missing. so ", in fact I burned this library to the ARM board and used the LD-LIBRARY-PATH to specify the related library ffmpeg, do not know why to study .) This version is a non-complete version. After repeated transplantation, you can use the camera for real-time monitoring, but cannot save the video.
-----------------------------------
The databases used are as follows:
I use the Qt library which is a qt-4.6.3 that contains libz1.2.5 so this library does not need to be installed.
1、jpegsrc.v8b.tar.gz
22.16libpng-1.2.18.tar.gz
32.16yasm-0.7.2.tar.gz
4、ffmpeg-0.9.2.tar.bz2
5、OpenCV-2.0.0.tar.bz2
Http://download.csdn.net/user/pk124729136 free resources
-----------------------------------
1. libjpeg cross-Compilation:
After decompression into the jpeg-8b directory:
# CC = arm-linux-gcc./configure -- prefix =/opt/ruanjian/Trolltech/qt-4.6.3 -- enable-shared
# Make
If the following error occurs after make :"
./Libtool -- mode = compile arm-linux-gcc-O2-I.-c./jcapimin. c
Make:./libtool: Command not found
Make: *** [jcapimin. lo] Error 127
Solution: Check whether there is any libtool in your system. If not, install one. Copy config. guess & config. sub to the jpeg directory:
# Cd/usr/share/libtool/config. sub ./
# Cd/usr/share/libtool/config. guess ./
Then execute
# Make install
2. Cross-Compilation of libpng
After decompression into the libpng-1.2.18 directory:
# CC = arm-linux-gcc./configure -- prefix =/opt/ruanjian/Trolltech/qt-4.6.3 -- enable-shared -- host = arm-linux
# Make
# Make install
4. Cross-Compilation of yasm:
Unzip the package and go to the yasm-0.7.2 directory.
# CC = arm-linux-gcc./configure -- prefix =/opt/ruanjian/Trolltech/qt-4.6.3 -- enable-shared -- host = arm-linux
# Make
# Make install
7. Cross-Compilation of ffmpeg:
After decompression into the ffmpeg-0.9.2 directory:
Note: ffmpeg may have some problems when using x264, such as "ERROR: x264 not found"
In this case, x264 is installed in the Cross Compiler. In addition, ffmpeg is recommended to use the latest version.
#. /Configure -- prefix =/opt/ruanjian/Trolltech/qt-4.6.3 -- enable-shared -- disable-static -- enable-gpl -- enable-cross-compile -- arch = arm -- disable-stripping -- target-OS = linux -- cc = arm-linux-gcc -- enable-swscale
# Make
# Make install
9. opencv2.0.0 cross-Compilation:
Decompress the package and go to the opencv2.0.0 directory. First, modify the configure file:
# Gedit configure
Search for-lavcodec and locate the location of approximately 18182 rows. Add "-lswscale" after "FFMPEGLIBS ="-lavcodec-lavformat "and change it: "FFMPEGLIBS ="-lavcodec-lavformat-lswscale $ FFMPEG_SWSCALE_LIBS "", save and exit.
#. /Configure -- prefix =/opt/ruanjian/Trolltech/qt-4.6.3 -- host = arm-linux -- without-gtk -- without-carbon -- without-quicktime -- without-1394libs -- without-python --- swig -- enable-static -- enable-shared -- disable-apps CXX = arm-linux-g ++ CPPFLAGS =-I/opt/ruanjian/Trolltech/qt-4.6.3/include LDFLAGS =-L /opt/ruanjian/Trolltech/qt-4.6.3/lib -- with-v4l
# Make
# Make install
If you encounter libz. la, libz. so, libz. so.1, libz. the so.1.2.3 file cannot be found under the Cross-compiler "arm-none-linux-gnueabi. la, in the directory where libz is installed compiled in step 1. In this case. so, libz. so.1, libz. "so.1.2.3", because the "libz. so, libz. so.1, libz. so.1.2.3 "must be compiled using the arm-linux-gcc cross compiler. After compilation, delete and restore the backup. Otherwise, the compilation process cannot be started normally. la, libz. so, libz. so.1, libz. the so.1.2.3 file cannot be found under the Cross-compiler "arm-none-linux-gnueabi. la, in the directory where libz is installed compiled in step 1. In this case. so, libz. so.1, libz. "so.1.2.3", because the "libz. so, libz. so.1, libz. so.1.2.3 "must be compiled using the arm-linux-gcc cross compiler. After compilation, delete and restore the backup. Otherwise, the backup cannot be started properly.
Add the following statement to the xxx. pro file when creating the project.
LIBS + =/opt/ruanjian/Trolltech/qt-4.6.3/lib/libcv. so \
/Opt/ruanjian/Trolltech/qt-4.6.3/lib/libcvaux. so \
/Opt/ruanjian/Trolltech/qt-4.6.3/lib/libcxcore. so \
/Opt/ruanjian/Trolltech/qt-4.6.3/lib/libhighgui. so \
// Opt/ruanjian/Trolltech/qt-4.6.3/lib/libml. so
NOTE: If opencv is developed using qt, if the error ":-1: error: collect2: ld returned 1 exit status" appears after the above configuration is used, add the compiled library to the qt library. In this case, the Library is burned into the arm board and then added to the qt library again (including libraries used during opencv transplantation ).
-----------------------------------
At this point, the porting of the opencv-2.0.0 is successful. Next, compile a Qt program and run it on the Development Board (this program has a label control on the graphic interface ).
Program code:
# Ifndef MAINWINDOW_H
# Define MAINWINDOW_H
# Include
# Include
# Include
# Include
# Include
Namespace Ui {
Class MainWindow;
}
Class MainWindow: public QMainWindow {
Q_OBJECT
Public:
MainWindow (QWidget * parent = 0 );
~ MainWindow ();
CvCapture * capture;
CvSize size;
CvVideoWriter * videoWrite;
QTimer * timer;
QImage * image;
Protected:
Void changeEvent (QEvent * e );
Void init ();
Private:
Ui: MainWindow * ui;
Private slots:
Void displayPicture ();
};
# Endif // MAINWINDOW_H
//////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////
# Include "mainwindow. h"
# Include "ui_main1_1_h"
MainWindow: MainWindow (QWidget * parent ):
QMainWindow (parent ),
Ui (new Ui: MainWindow)
{
Ui-> setupUi (this );
Init ();
}
MainWindow ::~ MainWindow ()
{
Delete ui;
CvReleaseVideoWriter (& videoWrite );
}
Void MainWindow: changeEvent (QEvent * e)
{
QMainWindow: changeEvent (e );
Switch (e-> type ()){
Case QEvent: LanguageChange:
Ui-> retranslateUi (this );
Break;
Default:
Break;
}
}
Void MainWindow: init ()
{
Timer = new QTimer;
Capture = cvCreateCameraCapture (0 );
Size = cvSize (1, 320,240 );
VideoWrite = cvCreateVideoWriter ("test. avi", CV_FOURCC ('M', 'J', 'P', 'G'), 10, size, 1 );
Connect (timer, SIGNAL (timeout (), this, SLOT (displayPicture ()));
Timer-> start (30 );
}
Void MainWindow: displayPicture ()
{
IplImage * frame = cvQueryFrame (capture );
CvCvtColor (frame, frame, CV_BGR2RGB );
Image = new QImage (unsigned char *) frame-> imageData, frame-> width, frame-> height, frame-> widthStep, QImage: Format_RGB888 );
Ui-> label-> setScaledContents (true );
Ui-> label-> setPixmap (QPixmap: fromImage (* image, Qt: AutoColor ));
CvWriteFrame (videoWrite, frame );
Delete image;
}
//////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////