| 0 意見 ]


OpenCV2.0推出已經有很長時間了,但是OpenCV中文站在Linux系統下仍然掛著1.0的安裝教程,最初按照OpenCV1.0的安裝源碼方法直接解壓,配置,安裝無奈錯誤不斷。
?
1
2
3
4
5
6
7
8
#解壓
tar zxvf opencv-2.0.0.tar.gz
cd opencv-2.0.0
#依賴性配置
./configure
#編譯
make
make install

也Google過不少資料,包括這篇這篇(這位同學奇特之處在於其他博文貌似都是某種中東文字寫的),不得不說Google在搜索這組關鍵詞(OpenCV 2.0 Ubuntu)上效果相當不好,讓我走了不少彎路。
不論使用兩篇中的哪一篇,其出錯信息基本都是一致
highgui/cvcap_ffmpeg.cpp:1213: warning: 『AVFormatContext* av_alloc_format_context()』 is deprecated (declared at /usr/include/ffmpeg/avformat.h:873)
我也曾針對這個出錯信息進行檢索,結果令人失望,大量證據表明,這個錯誤信息雖然常見,但是所發求助貼都基本無回應,且基本散佈在日語,俄語,阿拉伯文等各式蝌蚪文中,難道英語人群就沒有人遇到這個錯嗎?最終我在OpenCV官網wiki上找到了答案。
這篇Installation Guide對安裝過程給出了詳細的闡釋,縱觀整個結構,就會發現OpenCV中文站上的VS 08平台搭建與之非常相似,事實上,從2.0開始,OpenCV就用跨平台的GUI make 工具cmake對OpenCV在各個平台下的編譯給了給出了統一方法,在這裡用GUI的cmake就相當於之前的configure對軟件的編譯進行依賴性分析,而後期的make 和 make install 都可以用IDE完成或者terminal裡面直接完成。
對於我之前錯誤的修復,Willow Garag在wiki的一篇文章中 Ubuntu forum還專門開貼討論這一問題,總體思路就是ffmpeg最新的一個穩定版build刪掉了某個OpenCV裡面要用到的函數,致使make不過;解決方案就是用nightly build的ffmpeg,這個build裡面又重新包含了這個函數 :|
這次經歷中,我看到了cmake的強大,一些簡單的GUI交互就免去了用戶大量的命令行指令,使得這個configure非常之光快速。
同樣我也看到linux和win的不同之處,一個開源的系統必定蘊含的多種同樣開源且頻繁更新的視頻I/O,多個發行版的並行,致使這個錯誤發生。

| 0 意見 ]


「::」稱之為類別範圍解析(Class scope resolution)運算子,


在實作類別方法時,在::之前指明您要實作的是哪一個類別

利用這種寫法可以讓你在類別外的地方進行numbers類別中的output()函式的寫作工作.


譬如
類別名稱numbers :: 類別內的函式名稱output()


http://caterpillar.onlyfun.net/Gossip/CppGossip/CppGossip.html

入門基礎
        學習程式語言第一件事,通常就是先作個簡單的程式來運行一下,並從瞭解程式語言的資料型態、變數與流程控制語法開始。
  • 資料型態與變數
        無論如何 先來個 "Hello! World!" 顯示一下程式執行結果,增加一點撰寫程式的信心!接著就耐心的瞭解一下 C++ 的資料型態,以認識一下變數、常數。
  • 運算
        程式的目的簡單的說就是運算、運算還是運算,加減乘除這類的動作是少不得的,在C++中提供運算功能的就是運算子(Operator)。
  • 流程控制
        流程控制語法是程式設計的基本,藉由各種條件判斷與迴圈重覆執行語法,您可以令您的程式因應不同的狀況而作出不同的回應。


進階型態
        陣列、字串、指標這幾種C++的進階型態相當常被使用,雖然看似複雜,但彼此之間互有相關。
  • 陣列(Array)
        各種型態的陣列各有其不同的用途,但無論如何,先從基本型態的一維陣列、二維陣列開始認識起。
  • 向量(Vector)
        C++提供了內建陣列的替代型態 vector,vector 可以如同陣列一般的操作,並記得自己的長度資訊,您也可以使用物件的方式來操作 vector 。
  • 字串(String)
        字串的本質是字元陣列,而在C++中還可以使用string類別來表現字串,兩者都有瞭解的必要。
  • 指標(Pointer)
        指標可指向一個記憶體位址,可對物件作間接操作,指標擁有型態,這用來告訴編譯器如何解釋記憶體空間的內容,以及每一次運算的大小。


函式
        程式中超過兩次以上重複使用的程式碼,可以考慮將之定義為函式,以便重覆呼叫使用,降低相同程式片段的維護成本。
  • 函式入門
        先簡介一些與函式定義相關的幾個語法,並談談幾個變數可視範圍的議題。
  • 進階議題
        遞迴呼叫、傳值、傳址、傳參考等,這些議題在函式的使用上關乎執行資源的使用與效率問題。


物件基礎
        以物件為基礎的程式設計,將程式中互動的單元視為一個個的物件。
  • 封裝(Encapsulation)
        封裝物件資訊是第一步,您要瞭解如何使用類別定義物件,像是定義物件的屬性、行為等等,類別是建構物件 時所依賴的規格書。
        一些有關於指標、運算子重載、特殊型態類別的相關議題。


物件導向
以物件為基礎作延伸,多型(Polymorphism)操作為設計時的核心,於執行時期 動態繫結(Dynamic binding)以決定物件的行為。
  • 繼承(Inheritance)
        您可以繼承某個(父)類別的定義並加以擴充,而制訂出一個新的(子)類別定義。
        多型操作在物件 導向設計中伴演著極重要的角色,使用的適當與否,足以 影響程式的架構與未來的可維護性。

例外處理(Exception Handling)
        例外(Exception)是程式執行時期可偵測到的異常狀況,C++的例外處理包括兩部份:例外的丟出(throw)與例外的捕捉(catch)與處 理。

範本(Template)、名稱空間(Namespace)
        範本(Template)提供被參數化的型態(Parameterized Types)功能,將型態相依與非型態相依的演算法分離開來;名稱空間則提供一個名稱管理容器,減低名稱衝突的機會發生。

輸入/輸出
        來看看 C++ 中如何處理輸入/輸出,像是格式控制、檔案 I/O 等。
  • 格式控制與 <<、>> 運算子重載
        首先來看看基本的格式控制,以及 << 、 >> 運算子的重載。
        檔案的輸出輸入是 I/O 的基本,為認識 I/O 的入門必學。

附錄

| 0 意見 ]

http://doc.qt.nokia.com/qq/qq03-activex.html



ActiveX under Control
by Volker Hilsheimer

Microsoft's COM technology allows applications and libraries to use components provided by component servers, and to be component servers in their own right. ActiveX is built on the COM technology and defines a set of interfaces for both the client side and the server side. This article introduces the new ActiveQt framework that provides the QAxContainer and QAxServer modules supplied with Qt 3.1's Windows port.
Qt's new ActiveX support allows Qt/Windows developers to access and use ActiveX controls provided by ActiveX servers, and to make their own applications and shared libraries into ActiveX servers. For example, a Qt application could make use of Internet Explorer's ActiveX controls to provide a web page display and navigation to its users. Instead of working with the low-level generic API provided by Microsoft, developers use the QAxWidget class to write standard Qt code using familiar techniques such as signals and slots.
Using a pre-3.1 Qt or a generic ActiveX SDK to create ActiveX controls is very difficult. Qt 3.1's ActiveX support is designed to take the pain out of ActiveX programming. It insulates developers from all the different kinds of generated code that is normally part of an ActiveX implementation. Instead, developers use the QAxServer module to expose any QWidget class as a scriptable ActiveX control.

Using an ActiveX Control

The QAxWidget class uses the COM introspection interfaces (e.g. IDispatch) to generate Qt meta-object information for the ActiveX control it has been initialized with.
    #define CLSID_InternetExplorer "{8856F961-340A-11D0-A96B-00C04FD705A2}"
    QAxWidget *activeX = new QAxWidget( this );
    activeX->setControl( CLSID_InternetExplorer );
The meta-object information adds all the properties and methods exposed by the ActiveX control as Qt properties and slots. This means that we can use Qt's signals and slots mechanism with ActiveX controls. For example, Internet Explorer's GoHome() method becomes a GoHome() slot in Qt:
    connect( homeButton, SIGNAL(clicked()), activeX, SLOT(GoHome()) );
If the ActiveX control provides an event source, the QAxWidget object registers itself as an event sink and makes the events available as Qt signals. Qt's ActiveX framework handles all the type conversions between COM and Qt data types.
    connect( activeX, SIGNAL(TitleChange(const QString&)), 
             this, SLOT(setTitle(const QString&)) );
ActiveX events can be used like any other Qt signals. In this example we've connected Internet Explorer's TitleChange event to our own setTitle() slot.
    activeX->dynamicCall( "Navigate(const QString&)", 
                          "http://doc.trolltech.com" );
The dynamicCall() function allows developers to call a method in an ActiveX control. Qt's ActiveX framework dispatches the call through the IDispatch interface provided by the ActiveX control after doing the type conversions. If a lot of calls need to be made it may be inefficient to use the dynamicCall() approach.
    IWebBrowser *webBrowser = 0;
    activeX->queryInterface( IID_IWebBrowser, &webBrowser );
    if ( webBrowser ) {
       do_something_with( webBrowser );
       webBrowser->Release();
    }
The QAxWidget class provides direct access to the ActiveX control itself through the queryInterface() function. Using the COM interface directly is also useful for accessing methods and properties that have data types which cannot be converted by Qt's ActiveX framework, e.g. properties of type IDispatch *. A notable difference from standard Qt programming is that we must call Release() when we have finished using the control.

Creating an ActiveX Control Server
The ActiveQt framework provides a static library implementing the functions required to turn a standard Qt application or DLL into an ActiveX control server. The qmake build tool adds the necessary modifications to the build system when the list of CONFIG settings in the .pro file includes "activeqt":

    CONFIG += activeqt

Every class inheriting QWidget can be exposed by the server as an ActiveX control. The server must provide a factory that the framework can use to create QWidget objects when they are requested by an ActiveX client. To create an ActiveX server exposing only a single control, it is sufficient to use the default factory as a macro.
    #include 

    QAXFACTORY_DEFAULT( QTetrix, 
                "{852558AD-CBD6-4f07-844C-D1E8983CD6FC}", 
                "{2F5D0068-772C-4d1e-BCD2-D3F6BC7FD315}", 
                "{769F4820-9F28-490f-BA50-5545BD381DCB}", 
                "{5753B1A8-53B9-4abe-8690-6F14EC5CA8D0}", 
                "{DE2F7CE3-CFA7-4938-A9FC-867E2FEB63BA}" );
If the code shown above is added to the Qt Tetrix example (in file qtetrix.cpp), the game will become an ActiveX server. The parameters passed into the macro are unique IDs used by COM to identify the ActiveX control, the interfaces it implements, and its type information. Microsoft supply a tool, guidgen, for generating such IDs. To provide multiple ActiveX controls the factory must be implemented manually. This is achieved by subclassing the QAxFactory class and reimplementing the virtual functions to return information about the supported controls.
The qmake tool will add a build step after the linking of the executable to generate an interface definition file from the information provided by the Qt meta object system. The class's properties, signals and slots will be exposed by the framework as COM properties, methods and events, and will be accessible through the IDispatch automation interface.
Clients using the Tetrix ActiveX control ought to be able to start the game, and be able to read and write the current score, for example to maintain a high score table.
    class QTetrix : public QWidget
    {
        Q_OBJECT
        Q_PROPERTY( int score READ score WRITE setScore )
    public:
        QTetrix( QWidget *parent = 0, const char *name = 0 );
        int score() const;
    public slots:
        void startGame();
        void setScore( int score );
    signals:
        void gameOver();
    };
The Q_PROPERTY macro makes the score accessible to the Qt property system, and the ActiveQt framework exposes it as an ActiveX property. The public slots allow the score to be set and the game to be started using OLE automation, and the gameOver() signal is sent to the hosting client as an ActiveX event.
Applications that are ActiveX servers can also be run as stand alone applications. The following code removes widget functionality that might be inappropriate when they are used as ActiveX controls.
    if ( QAxFactory::isServer() )
        quitButton->hide();
Calling the application with -regserver registers it so that it can be instantiated and scripted by ActiveX clients.
    tetrix -regserver
ActiveX clients can use registered controls, for example
    
    
    
The HTML shown above embeds the QTetrix control into a webpage, and shows a "Start Game" button that will call the startGame() slot of the QTetrix widget.

Summing Up

The QAxContainer module provides QAxWidget, a subclass of QWidgetQAxWidget makes ActiveX methods, properties and events available as Qt slots, properties and signals so that developers can use ActiveX controls just like standard QObjects. The QAxServer module provides an interface between Qt widgets and ActiveX controls. It includes the QAxFactory class that is used to create ActiveX components. Widgets and components created with the QAxServer module can be instantiated and used as standard ActiveX controls by ActiveX client applications and scripting engines such as Internet Explorer and Visual Basic.