Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
8710c8d6
Commit
8710c8d6
authored
Jun 09, 2010
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed code samples
parent
e4115fa5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
15 deletions
+11
-15
opencv_cheatsheet.pdf
doc/opencv_cheatsheet.pdf
+0
-0
opencv_cheatsheet.tex
doc/opencv_cheatsheet.tex
+11
-15
No files found.
doc/opencv_cheatsheet.pdf
View file @
8710c8d6
No preview for this file type
doc/opencv_cheatsheet.tex
View file @
8710c8d6
...
...
@@ -183,7 +183,7 @@
\textbf
{
Create a matrix initialized with specified values
}
\\
\>
\texttt
{
double a = CV
\_
PI/3;
}
\\
\>
\texttt
{
Mat A22 =
Mat
(Mat
\_
<float>(2, 2) <<
}
\\
\>
\texttt
{
Mat A22 = (Mat
\_
<float>(2, 2) <<
}
\\
\>
\>
\texttt
{
cos(a), -sin(a), sin(a), cos(a));
}
\\
\>
\texttt
{
float B22data[] =
\{
cos(a), -sin(a), sin(a), cos(a)
\}
;
}
\\
\>
\texttt
{
Mat B22 = Mat(2, 2, CV
\_
32F, B22data).clone();
}
\\
...
...
@@ -199,7 +199,7 @@
\>
\texttt
{
Mat I(480, 640, CV
\_
32FC3, Idata);
}
\\
\>
\texttt
{
vector<Point> iptvec(10);
}
\\
\>
\texttt
{
Mat iP(iptvec);
}
\textit
{
// iP -- 10x1 CV
\_
32SC2 matrix
}
\\
\>
\texttt
{
CvMat* oldC0 = cvCreateImage(cvSize(320, 240), 16
);
}
\\
\>
\texttt
{
IplImage* oldC0 = cvCreateImage(cvSize(320,240),16,1
);
}
\\
\>
\texttt
{
Mat newC = cvarrToMat(oldC0);
}
\\
\>
\texttt
{
IplImage oldC1 = newC; CvMat oldC2 = newC;
}
\\
...
...
@@ -263,7 +263,7 @@
\begin{tabbing}
Exa
\=
mple 1. Smooth image ROI in-place
\\
\>\texttt
{
Mat imgroi = image(Rect(10, 20, 100, 100));
}
\\
\>\texttt
{
GaussianBlur(imgroi, imgroi,
5, 5
, 1.2, 1.2);
}
\\
\>\texttt
{
GaussianBlur(imgroi, imgroi,
Size(5, 5)
, 1.2, 1.2);
}
\\
Example 2. Somewhere in a linear algebra algorithm
\\
\>\texttt
{
m.row(i) += m.row(j)*alpha;
}
\\
Example 3. Copy image ROI to another image with conversion
\\
...
...
@@ -291,20 +291,16 @@ other matrix operations, such as
-- correspondingly, addition, subtraction, element-wise multiplication ... comparison of two matrices or a matrix and a scalar.
% (a, a, a, 255)*(r, g, b, a)/255
% 255 - (a, a, a, 255) = (255 - a, ..., 0)
% (b, b, b, b)*(255 - a, 255 - a, 255 - a, 0)/255 = ((255 - a)*b/255, ...., (255 - a))
\begin{tabbing}
Exa
\=
mple.
\href
{
http://en.wikipedia.org/wiki/Alpha
_
compositing
}{
Alpha compositing
}
function:
\\
\texttt
{
void alphaCompose(const Mat
\&
rgba1,
}
\\
\>
\texttt
{
const Mat
\&
rgba2, Mat
\&
rgba
\_
dest)
}
\\
\texttt
{
\{
}
\\
\>
\texttt
{
Mat a1(rgba1.size(), rgba1.type), ra1;
}
\\
\>
\texttt
{
Mat a2(rgba2.size(), rgba2.type);
}
\\
\>
\texttt
{
Mat a1(rgba1.size(), rgba1.type
()
), ra1;
}
\\
\>
\texttt
{
Mat a2(rgba2.size(), rgba2.type
()
);
}
\\
\>
\texttt
{
int mixch[]=
\{
3, 0, 3, 1, 3, 2, 3, 3
\}
;
}
\\
\>
\texttt
{
mixChannels(
\&
rgba1,
\&
a
1, mixch, 4);
}
\\
\>
\texttt
{
mixChannels(
\&
rgba2,
\&
a2
, mixch, 4);
}
\\
\>
\texttt
{
mixChannels(
\&
rgba1,
1,
\&
a1,
1, mixch, 4);
}
\\
\>
\texttt
{
mixChannels(
\&
rgba2,
1,
\&
a2, 1
, mixch, 4);
}
\\
\>
\texttt
{
subtract(Scalar::all(255), a1, ra1);
}
\\
\>
\texttt
{
bitwise
\_
or(a1, Scalar(0,0,0,255), a1);
}
\\
\>
\texttt
{
bitwise
\_
or(a2, Scalar(0,0,0,255), a2);
}
\\
...
...
@@ -362,7 +358,7 @@ Exa\=mple. \href{http://en.wikipedia.org/wiki/Alpha_compositing}{Alpha compositi
For some operations a more convenient
\href
{
http://opencv.willowgarage.com/documentation/cpp/basic
_
structures.html#matrix-expressions
}{
algebraic notation
}
can be used, for example:
\begin{tabbing}
\texttt
{
Mat
}
\=
{}
\texttt
{
delta = (J.t()*J + lambda*
}
\\
\>\texttt
{
Mat::eye(J.cols, J.cols, J.type())
}
\\
\>\texttt
{
Mat::eye(J.cols, J.cols, J.type())
)
}
\\
\>\texttt
{
.inv(CV
\_
SVD)*(J.t()*err);
}
\end{tabbing}
implements the core of Levenberg-Marquardt optimization algorithm.
...
...
@@ -393,8 +389,8 @@ implements the core of Levenberg-Marquardt optimization algorithm.
\begin{tabbing}
Exa
\=
mple. Filter image in-place with a 3x3 high-pass filter
\\
\>
(preserve negative responses by shifting the result by 128):
\\
\texttt
{
filter2D(image, image, image.depth(),
Mat(Mat
\_
<float>(3,3)
}
\\
\>
\texttt
{
<<
-1, -1, -1, -1, 9, -1, -1, -1, -1), Point(1,1), 128);
}
\\
\texttt
{
filter2D(image, image, image.depth(),
(Mat
\_
<float>(3,3)<<
}
\\
\>
\texttt
{
-1, -1, -1, -1, 9, -1, -1, -1, -1), Point(1,1), 128);
}
\\
\end{tabbing}
\subsection
{
Geometrical Transformations
}
...
...
@@ -506,7 +502,7 @@ samples on what are the contours and how to use them.
\texttt
{
CV
\_
Assert(tl.type() == FileNode::SEQ
\&\&
tl.size() == 3);
}
\\
\texttt
{
double tl0 = (double)tl[0]; string tl1 = (string)tl[1];
}
\\
\texttt
{
int m = (int)tl[2]["month"], d = (int)tl[2]["day"]
}
;
\\
\texttt
{
int m = (int)tl[2]["month"], d = (int)tl[2]["day"]
;
}
\\
\texttt
{
int year = (int)tl[2]["year"];
}
\\
\texttt
{
FileNode tm = fs["mystruct"];
}
\\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment