diff --git a/doc/goman b/doc/goman new file mode 100644 index 0000000000..de86424e6e --- /dev/null +++ b/doc/goman @@ -0,0 +1,6 @@ +(pdflatex '\newcommand{\genc}{true}\newcommand{\genpy}{true}\newcommand{\targetlang}{c}\input{opencv_user.tex}' && +# bibtex opencv_user && +# makeindex opencv_user && + pdflatex '\newcommand{\genc}{true}\newcommand{\genpy}{true}\newcommand{\targetlang}{c}\input{opencv_user.tex}' > 1 + ) || exit 1 +#gv -page=480 opencv_user.pdf diff --git a/doc/opencv_guide_body.tex b/doc/opencv_guide_body.tex new file mode 100644 index 0000000000..52eeae3013 --- /dev/null +++ b/doc/opencv_guide_body.tex @@ -0,0 +1,5 @@ + +\chapter{cv::Mat. Basic operations with images.} +\renewcommand{\curModule}{Working with images.} +\input{user_mat} + diff --git a/doc/opencv_user.pdf b/doc/opencv_user.pdf new file mode 100644 index 0000000000..1b72ddad53 Binary files /dev/null and b/doc/opencv_user.pdf differ diff --git a/doc/opencv_user.tex b/doc/opencv_user.tex new file mode 100644 index 0000000000..d0aad83d8b --- /dev/null +++ b/doc/opencv_user.tex @@ -0,0 +1,107 @@ +\documentclass[11pt]{book} + +\usepackage{cite} +\usepackage[pdftex]{graphicx} +\usepackage{titlesec} +\usepackage{listings} +\usepackage{fancyvrb} +\usepackage[svgnames]{xcolor} +\usepackage{framed} +\usepackage{amsmath} +\usepackage{amssymb} +\usepackage{bbm} +\usepackage{hyperref} +\usepackage{makeidx} +\usepackage{color} +\usepackage{verbatim} + +\setcounter{secnumdepth}{1} + +\definecolor{shadecolor}{gray}{0.95} % Background color of title bars +\lstset{ +language=C, +basicstyle=\small\ttfamily, +backgroundcolor=\color{shadecolor} +} + +\definecolor{cvlinkcolor}{rgb}{0.0 0.3 0.8} + +% taken from http://en.wikibooks.org/wiki/LaTeX/Hyperlinks +\hypersetup{ + bookmarks=true, % show bookmarks bar? + unicode=false, % non-Latin characters in Acrobat’s bookmarks + %pdftoolbar=true, % show Acrobat’s toolbar? + %pdfmenubar=true, % show Acrobat’s menu? + %pdffitwindow=false, % window fit to page when opened + %pdfstartview={FitH}, % fits the width of the page to the window + %pdftitle={My title}, % title + %pdfauthor={Author}, % author + %pdfsubject={Subject}, % subject of the document + %pdfcreator={Creator}, % creator of the document + %pdfproducer={Producer}, % producer of the document + %pdfkeywords={keywords}, % list of keywords + %pdfnewwindow=true, % links in new window + colorlinks=true, % false: boxed links; true: colored links + linkcolor=cvlinkcolor, % color of internal links + citecolor=cvlinkcolor, % color of links to bibliography + filecolor=magenta, % color of file links + urlcolor=cyan % color of external links +} + +\makeindex + +\newcommand{\piRsquare}{\pi r^2} % This is my own macro !!! + +\usepackage{helvetica} +\usepackage{ifthen} +\usepackage{alltt} +\usepackage{opencv} + +%%% Margins %%% +\oddsidemargin 0.0in +\evensidemargin 0.0in +\textwidth 6.5in +%\headheight 1.0in +%\topmargin 0.5in +%\textheight 9.0in +%\footheight 1.0in +%%%%%%%%%%%%%%% + +\title{OpenCV User Guide} % used by \maketitle +\author{v2.2} % used by \maketitle +\date{December, 2010} % used by \maketitle + +\begin{document} +\maketitle % automatic title! + +\setcounter{tocdepth}{8} +\tableofcontents + +\titleformat{\subsection} +{\titlerule +\vspace{.8ex}% +\normalfont\bfseries\Large} +{\thesection.}{.5em}{} + +%%% Define these to get rid of warnings +\def\genc{true} +\def\genpy{true} +\def\gencpp{true} + +\newif\ifC +\newif\ifPy +\newif\ifCpp +\newif\ifCPy + +\Cfalse +\Cpptrue +\Pyfalse +\CPyfalse +\def\targetlang{cpp} +\part{C++ API Reference} +\input{opencv_guide_body} + +\addcontentsline{toc}{part}{Index} +\printindex + +\end{document} % End of document. diff --git a/doc/user_mat.tex b/doc/user_mat.tex new file mode 100644 index 0000000000..731e7b0a47 --- /dev/null +++ b/doc/user_mat.tex @@ -0,0 +1,43 @@ +\section{Basic operations with images} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% C++ % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\ifCpp +\subsection{Input/Output} +Load an image from a file: +\begin{lstlisting} +Mat img = imread(filename); +\end{lstlisting} + +If you read a jpg file, a 3 channel image is created by default. If you need a grayscale image, use: +\begin{lstlisting} +Mat img = imread(filename, 0); +\end{lstlisting} + +Save an image to a file: +\begin{lstlisting} +Mat img = imwrite(filename); +\end{lstlisting} + +\subsection{Accessing pixel intensity values} + +In order to get pixel intensity value, you have to know the type of an image and the number of channels. Here is an example for a single channel grey scale image (type 8UC1) and pixel coordinates x and y: +\begin{lstlisting} +Scalar intensity = img.at(x, y); +\end{lstlisting} +\texttt{intensity.val[0]} contains a value from 0 to 255. + +Now let us consider a 3 channel image with \texttt{bgr} color ordering (the default format returned by imread): +\begin{lstlisting} +Scalar intensity = img.at(x, y); +uchar blue = intensity.val[0]; +uchar green = intensity.val[1]; +uchar red = intensity.val[2]; +\end{lstlisting} +\fi + +