OpenCV/Method to control of pixel value drawing in Qt Window

#multilang(ja){{

概要

OpenCV 2.3.1(Qt有効版)で画像を表示した場合,デフォルトでは一定倍率以上拡大すると
常に画素値が表示されます.本パッチはこの画素値表示機能の動的な切り替えを可能とします.


control_of_pixel_value_drawing.png


ダウンロード

VersionFilenameSizeDateTypeDownload
1.0opencv_qt_window_extension_v1.zip37.3 KB20111008ziphttp://www.atinfinity.info/opencv/extension/opencv_qt_window_extension_v1.zip

変更履歴

VersionDate変更内容
1.020111008新規作成

使い方

  1. 上記リンクからopencv_qt_window_extension_v1.zipをダウンロードして展開します.
  2. 展開したhighguiディレクトリを下記ディレクトリに上書きして下さい.
    OpenCV-2.3.1\modules\highgui
  3. CMakeでWITH_QTを有効にしてビルドしてください.

追加されるウィンドウプロパティと値

cv::setWindowProperty?関数, cv::getWindowProperty?関数で用いることができる
ウィンドウプロパティ,値として下記のものが追加されます.

ウィンドウプロパティ

prop_idCV_WND_PROP_DRAW_PIXEL_VAL

prop_valueCV_WINDOW_ENABLE_DRAW_PIXEL_VAL
CV_WINDOW_DISABLE_DRAW_PIXEL_VAL

サンプルプログラム

filecontrol_of_pixel_value_drawing.cpp
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

#ifdef _DEBUG
    #pragma comment( lib, "opencv_core231d.lib" )
    #pragma comment( lib, "opencv_imgproc231d.lib" )
    #pragma comment( lib, "opencv_highgui231d.lib" )
#else
    #pragma comment( lib, "opencv_core231.lib" )
    #pragma comment( lib, "opencv_imgproc231.lib" )
    #pragma comment( lib, "opencv_highgui231.lib" )
#endif

using namespace std;

int main(int argc, char *argv[])
{
    if(argc < 2)
    {
        cout << "[usage]" << argv[0] << " filename" << endl;
        return -1;
    }

    cv::Mat src_img = cv::imread(argv[1], CV_LOAD_IMAGE_UNCHANGED);
    cv::namedWindow("src", CV_WINDOW_AUTOSIZE | CV_WINDOW_FREERATIO | CV_GUI_EXPANDED);
    cv::setWindowProperty("src", CV_WND_PROP_DRAW_PIXEL_VAL, CV_WINDOW_ENABLE_DRAW_PIXEL_VAL);
    cv::imshow("src", src_img);
    cv::waitKey(0);
    cv::destroyAllWindows();

    return 0;
}

Contact

間違い・御指摘等ありましたら,

mail.png

までメールにてご連絡ください. }}

#multilang(en){{

Abstract

On the OpenCV 2.3.1(WITH_QT), if you zoom in than certain value, the pixel value is always displayed.
This page describes the method to switch enable/disable drawing pixel value on OpenCV 2.3.1.


control_of_pixel_value_drawing.png


Download

VersionFilenameSizeDateTypeDownload
1.0opencv_qt_window_extension_v1.zip37.3 KB20111008ziphttp://www.atinfinity.info/opencv/extension/opencv_qt_window_extension_v1.zip

ChangeLog?

VersionDateChanges
1.020111008First Release

Usage

  1. Please download opencv_qt_window_extension_v1.zip. And, extract this file.
  2. Please overwrite extracted highgui directory to the following directory
    OpenCV-2.3.1\modules\highgui
  3. Please enable "WITH_QT" on CMake, and build OpenCV.

Added window property and values

If you apply this patch, you can use the following window property and values
as arguments of cv::setWindowProperty? and cv::getWindowProperty?.

Window property

prop_idCV_WND_PROP_DRAW_PIXEL_VAL

Values

prop_valueCV_WINDOW_ENABLE_DRAW_PIXEL_VAL
CV_WINDOW_DISABLE_DRAW_PIXEL_VAL

Sample program

filecontrol_of_pixel_value_drawing.cpp
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

#ifdef _DEBUG
    #pragma comment( lib, "opencv_core231d.lib" )
    #pragma comment( lib, "opencv_imgproc231d.lib" )
    #pragma comment( lib, "opencv_highgui231d.lib" )
#else
    #pragma comment( lib, "opencv_core231.lib" )
    #pragma comment( lib, "opencv_imgproc231.lib" )
    #pragma comment( lib, "opencv_highgui231.lib" )
#endif

using namespace std;

int main(int argc, char *argv[])
{
    if(argc < 2)
    {
        cout << "[usage]" << argv[0] << " filename" << endl;
        return -1;
    }

    cv::Mat src_img = cv::imread(argv[1], CV_LOAD_IMAGE_UNCHANGED);
    cv::namedWindow("src", CV_WINDOW_AUTOSIZE | CV_WINDOW_FREERATIO | CV_GUI_EXPANDED);
    cv::setWindowProperty("src", CV_WND_PROP_DRAW_PIXEL_VAL, CV_WINDOW_ENABLE_DRAW_PIXEL_VAL);
    cv::imshow("src", src_img);
    cv::waitKey(0);
    cv::destroyAllWindows();

    return 0;
}

Contact

If you have question,please send e-mail to the following address.

mail.png }}


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2011-10-09 (日) 02:23:00 (2143d)