| 214 | ---- |
| 215 | ---- |
| 216 | ---- |
| 217 | === C++ Projects with OpenCV === |
| 218 | '''NOTE: our performance doubled when we transitioned to C++ from Java''' |
| 219 | |
| 220 | Let's install an IDE so we do not have to keep writing in vi/vim/nano: |
| 221 | {{{ |
| 222 | sudo apt-get install codeblocks |
| 223 | }}} |
| 224 | |
| 225 | We experienced a bug that constantly crashed CodeBlocks: |
| 226 | Navigate to: {{{Settings -> Editor -> Code completion -> Symbols browser}}} and check {{{Disable symbols browser}}} |
| 227 | (the {{{Code completion}}} tab is on the west panel of the configure editor.) |
| 228 | |
| 229 | Navigate to: {{{File -> New -> Project -> Console Application}}} |
| 230 | and fill in the fields that come up. |
| 231 | |
| 232 | If your {{{Management}}} tab is not visible, open it by selecting: {{{View -> Manager}}} |
| 233 | Also, if your {{{Logs & others}}} tab is not open already, select {{{View -> Logs}}} |
| 234 | |
| 235 | Now right click your project in the {{{Management}}} tab and navigate to: {{{Build options... -> Linker settings}}} |
| 236 | |
| 237 | Under the {{{Link libraries}}} panel, select {{{Add}}} and select all OpenCV shared object (.so) files located in {{{/home/pi/opencv/build/lib/*.so}}} |
| 238 | (You can [ctrl + left-click] multiple *.so] files to add them all at once) |
| 239 | |
| 240 | Now let's navigate to: {{{Search directories -> Linker}}} |
| 241 | In the {{{Linker}}} tab, select {{{Add}}} and add the path to your opencv lib: {{{/home/pi/opencv/build/lib}}} |
| 242 | |
| 243 | ===== Tricks and Tips ===== |
| 244 | Using OpenCV with the Raspberry Pi 3 ribbon cable camera is a little cumbersome because you cannot use many of the VideoCapture.set(char*,int) functions.[[BR]] |
| 245 | Instead, we use system commands to set camera settings via the v4l2-ctl library. |
| 246 | |
| 247 | For FRC retroreflective tape segmentation, use the following system commands to prevent auto adjustment features such as {{{auto exposure}}}, {{{white balance}}}, and {{{exposure time}}}: |
| 248 | * v4l2-ctl --set-ctrl=auto_exposure=1 |
| 249 | * v4l2-ctl --set-ctrl=white_balance_auto_preset=0 |
| 250 | * v4l2-ctl --set-ctrl=auto_exposure_bias=0 |
| 251 | * v4l2-ctl --set-ctrl=exposure_time_absolute=100 |
| 252 | |
| 253 | Make your C++ program set these options by using the {{{stdlib.h}}} {{{system(char*)}}} command which simply takes a string command as input. |