mirror of
https://github.com/jlengrand/Programming_Tips.git
synced 2026-03-10 00:31:21 +00:00
Adds OpenCV tips
This commit is contained in:
68
opencv.md
Normal file
68
opencv.md
Normal file
@@ -0,0 +1,68 @@
|
||||
# OpenCV
|
||||
|
||||
Memos and Tips about the OpenCV library.
|
||||
|
||||
## In C/C++:
|
||||
|
||||
### Placing a pointer to the beginning of pixel in an image:
|
||||
|
||||
Can be used to naviguate through pixels easily (and more efficiently than some openCV functions).
|
||||
|
||||
```C
|
||||
char *pImage = iplImage->ImageData
|
||||
```
|
||||
|
||||
|
||||
### Short review of the IplImage structure:
|
||||
|
||||
What’s really needed to work with an Image
|
||||
```C
|
||||
* IplImage struct {
|
||||
depth # Number of channels (gray level, color, . . .)
|
||||
sizeX
|
||||
sizeY
|
||||
* ImageData } #Pixels of the image
|
||||
...}
|
||||
```
|
||||
|
||||
|
||||
### Simple tips for Image Processing optimization in C:
|
||||
|
||||
An image is stored in a memory a a long line (n*m size)
|
||||
|
||||
Always go __trough the buffer way__, and not the opposite!
|
||||
```C
|
||||
for (i in nb_lines):
|
||||
for (j in nb_cols):
|
||||
//do stuff
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
and
|
||||
|
||||
```C
|
||||
for (j in nb_cols):
|
||||
for (i in nb_lines):
|
||||
//do stuff
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
are different ! **The second one is 10% faster than the other !**
|
||||
|
||||
##In Python :
|
||||
|
||||
Error on compiling OpenCV with Python bindings:
|
||||
|
||||
If you get this error when trying to compile OpenCV in Linux
|
||||
```bash
|
||||
Could NOT find PythonLibs (missing: PYTHON_INCLUDE_DIRS) in cmake
|
||||
```
|
||||
|
||||
Simply try installing python-dev packages.
|
||||
```bash
|
||||
$ sudo apt-get install python-dev
|
||||
```
|
||||
|
||||
It should solve the problem.
|
||||
@@ -12,6 +12,7 @@ $ svn cp trunk -> new_branch
|
||||
```bash
|
||||
$ svn update
|
||||
```
|
||||
|
||||
__**NOTE:** The command is an update and not a commit, as this is the server who performed the operation!__
|
||||
|
||||
You’re done!
|
||||
|
||||
Reference in New Issue
Block a user