{"id":680,"date":"2015-09-01T09:22:00","date_gmt":"2015-09-01T16:22:00","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=680"},"modified":"2023-07-12T18:17:20","modified_gmt":"2023-07-13T01:17:20","slug":"using-raspberry-pi-2-camera-from-c-programs-with-visual-studio","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/raspberry\/camera\/","title":{"rendered":"Using Raspberry Pi 2 Camera from C++ Programs with Visual Studio"},"content":{"rendered":"<p>This tutorial shows how to use the Raspberry Pi 2 camera from C++ programs developed with Visual Studio and VisualGDB. Before you begin, install VisualGDB 5.0r5 or later. We will also show how to get the latest Raspberry Pi Jessie image and use the corresponding cross-toolchain for faster compilation.<\/p>\n<ol>\n<li>Download the <a href=\"http:\/\/gnutoolchains.com\/raspberry\/jessie\/\">Raspberry Pi Jessie image<\/a> and write it to the SD card. Ensure you select the &#8220;Extend the Ext2FS partition&#8221; checkbox so that the Linux partition can fit the entire SD card:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/01-flash.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-681\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/01-flash.png\" alt=\"01-flash\" width=\"640\" height=\"481\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/01-flash.png 640w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/01-flash-300x225.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/li>\n<li>Start Visual Studio and open the VisualGDB Linux project Wizard:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/02-newprj1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-682\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/02-newprj1.png\" alt=\"02-newprj\" width=\"800\" height=\"481\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/02-newprj1.png 800w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/02-newprj1-300x180.png 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><\/li>\n<li>Select &#8220;Application (executable file)&#8221; to create a new application project:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/03-newprj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-683\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/03-newprj.png\" alt=\"03-newprj\" width=\"696\" height=\"628\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/03-newprj.png 696w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/03-newprj-300x271.png 300w\" sizes=\"(max-width: 696px) 100vw, 696px\" \/><\/a><strong>Warning: this tutorial uses GNU Make, that is not recommended for new projects and may not work with the latest Raspberry Pi toolchain. Please consider using Advanced CMake or MSBuild instead. <\/strong><\/li>\n<li>If you have not installed the Jessie toolchain for Raspberry Pi yet, you can select &#8220;download more toolchains&#8221; and then pick the toolchain from the list. Ensure you select the latest Jessie toolchain:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/jessie.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-690\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/jessie.png\" alt=\"jessie\" width=\"524\" height=\"273\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/jessie.png 524w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/jessie-300x156.png 300w\" sizes=\"(max-width: 524px) 100vw, 524px\" \/><\/a><\/li>\n<li>Select the connection settings in the &#8220;Deployment computer&#8221; field or choose &#8220;Create a new SSH connection&#8221; if you have not connected to your Raspberry Pi\u00a0 from VisualGDB before:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/04-jessie1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-691\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/04-jessie1.png\" alt=\"04-jessie\" width=\"696\" height=\"628\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/04-jessie1.png 696w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/04-jessie1-300x271.png 300w\" sizes=\"(max-width: 696px) 100vw, 696px\" \/><\/a><\/li>\n<li>Press &#8220;Finish&#8221; to create your project. VisualGDB will test the toolchain and ensure that it can build code that runs on your Raspberry Pi without any problems:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/05-test.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-685\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/05-test.png\" alt=\"05-test\" width=\"695\" height=\"628\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/05-test.png 695w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/05-test-300x271.png 300w\" sizes=\"(max-width: 695px) 100vw, 695px\" \/><\/a><\/li>\n<li>VisualGDB may detect that the PATH variable is configured differently for interactive SSH sessions and commands started via SSH, potentially interfering with GDB debugging. Select &#8220;Fix value&#8221; to resolve this automatically:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/06-fixenv.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-686\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/06-fixenv.png\" alt=\"06-fixenv\" width=\"640\" height=\"480\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/06-fixenv.png 640w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/06-fixenv-300x225.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/li>\n<li>Build your project, set a breakpoint on the return statement and run it with F5. Check the output in the &#8220;gdbserver&#8221; window for the &#8220;Hello, World&#8221; message:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/07-hello.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-687\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/07-hello.png\" alt=\"07-hello\" width=\"699\" height=\"605\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/07-hello.png 699w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/07-hello-300x260.png 300w\" sizes=\"(max-width: 699px) 100vw, 699px\" \/><\/a><\/li>\n<li>Now we will configure the Raspberry Pi to use the camera module. Open the SSH Console via Debug-&gt;Windows-&gt;SSH Console:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/08-shell.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-688\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/08-shell.png\" alt=\"08-shell\" width=\"699\" height=\"607\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/08-shell.png 699w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/08-shell-300x261.png 300w\" sizes=\"(max-width: 699px) 100vw, 699px\" \/><\/a><\/li>\n<li>Click on the &#8220;open a new shell&#8221; link and run the &#8220;sudo raspi-config&#8221; command. Then use the arrow keys to enable the camera module:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/09-camera.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-689\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/09-camera.png\" alt=\"09-camera\" width=\"699\" height=\"852\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/09-camera.png 699w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/09-camera-246x300.png 246w\" sizes=\"(max-width: 699px) 100vw, 699px\" \/><\/a><\/li>\n<li>Select &#8220;Finish&#8221; and shutdown your Raspberry Pi. Once the power is unplugged, connect the camera module as shown below:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/camera.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-693\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/camera.jpg\" alt=\"camera\" width=\"700\" height=\"338\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/camera.jpg 700w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/camera-300x145.jpg 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/a><\/li>\n<li>We will use the <a href=\"https:\/\/sourceforge.net\/projects\/raspicam\/files\/?\">Raspicam library from SourceForge<\/a> to connect to the camera from C++ code. Download the latest source package and extract it somewhere on your Windows machine. Now we will import it to your Visual Studio solution by adding another project:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/10-newprj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-694\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/10-newprj.png\" alt=\"10-newprj\" width=\"699\" height=\"628\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/10-newprj.png 699w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/10-newprj-300x270.png 300w\" sizes=\"(max-width: 699px) 100vw, 699px\" \/><\/a><\/li>\n<li>Specify the name and location for the wrapper project. It can be a different folder than the one with the sources of raspicam:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/11-raspicam.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-695\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/11-raspicam.png\" alt=\"11-raspicam\" width=\"800\" height=\"450\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/11-raspicam.png 800w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/11-raspicam-300x169.png 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><\/li>\n<li>On the first page of the wizard select &#8220;Import a project&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/12-importcmake.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-696\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/12-importcmake.png\" alt=\"12-importcmake\" width=\"696\" height=\"628\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/12-importcmake.png 696w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/12-importcmake-300x271.png 300w\" sizes=\"(max-width: 696px) 100vw, 696px\" \/><\/a><\/li>\n<li>The next page will show the last used toolchain and computer locations. Click on the &#8220;cross-compiler&#8221; option and VisualGDB will load the last used settings automatically:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/13-machine.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-697\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/13-machine.png\" alt=\"13-machine\" width=\"696\" height=\"628\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/13-machine.png 696w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/13-machine-300x271.png 300w\" sizes=\"(max-width: 696px) 100vw, 696px\" \/><\/a><\/li>\n<li>On the last page specify the location of CMake on your Windows machine (you can download CMake for Windows <a href=\"http:\/\/www.cmake.org\/download\/\">here<\/a>) and the directory where you have extracted the raspicam library:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/14-cmakeimp.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-698\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/14-cmakeimp.png\" alt=\"14-cmakeimp\" width=\"696\" height=\"628\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/14-cmakeimp.png 696w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/14-cmakeimp-300x271.png 300w\" sizes=\"(max-width: 696px) 100vw, 696px\" \/><\/a><\/li>\n<li>Before you can build the raspicam library, you need to download the \/opt\/vc directory from Raspberry Pi to the toolchain sysroot folder. This can be done by opening VisualGDB Project Properties, going to the Makefile Settings page, clicking &#8220;Synchronize Sysroot&#8221; and adding the &#8220;\/opt\/vc&#8221; folder to the folder list: <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/15-opt-vc.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-699\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/15-opt-vc.png\" alt=\"15-opt-vc\" width=\"885\" height=\"672\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/15-opt-vc.png 885w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/15-opt-vc-300x228.png 300w\" sizes=\"(max-width: 885px) 100vw, 885px\" \/><\/a><\/li>\n<li>The raspicam library checks the CMAKE_SYSTEM_PROCESSOR library to determine when it&#8217;s being built on Raspberry Pi. To support this, we need to specify the variable manually in the CMake project properties:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/17-processor.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-703\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/17-processor.png\" alt=\"17-processor\" width=\"796\" height=\"600\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/17-processor.png 796w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/17-processor-300x226.png 300w\" sizes=\"(max-width: 796px) 100vw, 796px\" \/><\/a><\/li>\n<li>If you try building the project now, CMake will complain that the mmal libraries are not found:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/16-mmal.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-702\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/16-mmal.png\" alt=\"16-mmal\" width=\"699\" height=\"625\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/16-mmal.png 699w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/16-mmal-300x268.png 300w\" sizes=\"(max-width: 699px) 100vw, 699px\" \/><\/a><\/li>\n<li>This happens because the library search paths in CMakeLists.txt are hardcoded to \/opt\/vc and do not use the sysroot variable. Modify CMakeLists.txt accordingly to fix this:\n<pre class=\"\">FIND_LIBRARY(mmalcore_LIBS NAMES mmal_core PATHS ${CMAKE_SYSROOT}\/opt\/vc\/lib)\r\nFIND_LIBRARY(mmalutil_LIBS NAMES mmal_util PATHS ${CMAKE_SYSROOT}\/opt\/vc\/lib)\r\nFIND_LIBRARY(mmal_LIBS NAMES mmal PATHS ${CMAKE_SYSROOT}\/opt\/vc\/lib)<\/pre>\n<\/li>\n<li>Now you should be able to build the RaspiCam project successfully:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/18-build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-704\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/18-build.png\" alt=\"18-build\" width=\"699\" height=\"626\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/18-build.png 699w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/18-build-300x269.png 300w\" sizes=\"(max-width: 699px) 100vw, 699px\" \/><\/a><\/li>\n<li>In order to use the header files and libraries from the project add the corresponding paths to the include and library directories of your main project. Also add &#8220;raspicam&#8221; to the library list so that the project is linked against it:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/19-settings.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-705\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/19-settings.png\" alt=\"19-settings\" width=\"792\" height=\"660\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/19-settings.png 792w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/19-settings-300x250.png 300w\" sizes=\"(max-width: 792px) 100vw, 792px\" \/><\/a><\/li>\n<li>Finally, add a project reference to the RaspiCam library from your main project so that Visual Studio knows in which order to build the projects:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/20-prjref.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-706\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/20-prjref.png\" alt=\"20-prjref\" width=\"766\" height=\"444\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/20-prjref.png 766w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/20-prjref-300x174.png 300w\" sizes=\"(max-width: 766px) 100vw, 766px\" \/><\/a><\/li>\n<li>Now we can add some code using the camera to the main source file:\n<pre class=\"\">#include &lt;fstream&gt;\r\n#include &lt;iostream&gt;\r\n#include &lt;vector&gt;\r\n#include &lt;raspicam.h&gt;\r\n#include &lt;unistd.h&gt;\r\n\r\nusing namespace std;\r\n\r\n\r\nint main(int argc, char **argv) \r\n{\r\n\u00a0\u00a0 \u00a0raspicam::RaspiCam camera;\r\n\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0if (!camera.open()) \r\n\u00a0\u00a0 \u00a0{\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0cerr &lt;&lt; \"Could not open the camera\" &lt;&lt; endl; \r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0return 1;\r\n\u00a0\u00a0 \u00a0}\r\n\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0cout &lt;&lt; \"Initial delay...\" &lt;&lt; endl;\r\n\u00a0\u00a0 \u00a0sleep(3);\r\n\u00a0\u00a0 \u00a0cout &lt;&lt; \"Acquiring image...\" &lt;&lt; endl;\r\n\u00a0\u00a0 \u00a0camera.grab();\r\n\r\n\u00a0\u00a0 \u00a0std::vector&lt;unsigned char&gt; buf;\r\n\u00a0\u00a0 \u00a0buf.resize(camera.getImageTypeSize(raspicam::RASPICAM_FORMAT_RGB));\r\n\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0camera.retrieve(buf.data(), raspicam::RASPICAM_FORMAT_RGB);\r\n\r\n\u00a0\u00a0 \u00a0std::ofstream outFile(\"output.ppm\", std::ios::binary);\r\n\u00a0\u00a0 \u00a0outFile &lt;&lt; \"P6\\n\" &lt;&lt; camera.getWidth() &lt;&lt; \" \" &lt;&lt; camera.getHeight() &lt;&lt; \" 255\\n\";\r\n\u00a0\u00a0 \u00a0outFile.write((char*)buf.data(), buf.size());\r\n\r\n\u00a0\u00a0 \u00a0cout &lt;&lt; \"Image saved to output.ppm\" &lt;&lt; endl;\r\n\u00a0\u00a0 \u00a0return 0;\r\n}<\/pre>\n<\/li>\n<li>If you build the project and start debugging it now, VisualGDB will report that the session could not be started and the detail window will show a missing shared library:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/21-library.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-707\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/21-library.png\" alt=\"21-library\" width=\"711\" height=\"400\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/21-library.png 711w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/21-library-300x169.png 300w\" sizes=\"(max-width: 711px) 100vw, 711px\" \/><\/a><\/li>\n<li>This happens because the CMake files in the RaspiCam project specify a lot of different targets and VisualGDB does not know which of them should be deployed. Open VisualGDB Project Properties for the library project and specify the missing library as the explicit debugged executable:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/22-sofile.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-708\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/22-sofile.png\" alt=\"22-sofile\" width=\"812\" height=\"655\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/22-sofile.png 812w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/22-sofile-300x242.png 300w\" sizes=\"(max-width: 812px) 100vw, 812px\" \/><\/a><\/li>\n<li>As VisualGDB deploys the outputs of the debugged project and all projects referenced by it, this will ensure that the library gets deployed along with the main binary and you should be able to run and step through the program:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/23-step.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-709\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/23-step.png\" alt=\"23-step\" width=\"699\" height=\"624\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/23-step.png 699w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/23-step-300x268.png 300w\" sizes=\"(max-width: 699px) 100vw, 699px\" \/><\/a><\/li>\n<li>Once the program exits, you can check the output window to see that the image has been written successfully:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/24-output.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-710\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/24-output.png\" alt=\"24-output\" width=\"699\" height=\"628\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/24-output.png 699w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/24-output-300x270.png 300w\" sizes=\"(max-width: 699px) 100vw, 699px\" \/><\/a><\/li>\n<li>If you are using a Custom edition or higher, you can configure VisualGDB to automatically convert the image to a .jpg one and download it to the Windows machine. Install the &#8220;netpbm&#8221; package on Raspberry Pi by running &#8220;sudo apt-get install netpbm&#8221; and add 2 actions shown below to the post-debug action list:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/25-custom.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-711\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/25-custom.png\" alt=\"25-custom\" width=\"964\" height=\"744\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/25-custom.png 964w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/25-custom-300x232.png 300w\" sizes=\"(max-width: 964px) 100vw, 964px\" \/><\/a><\/li>\n<li>If you run your project now, you should be able to see the output.jpg file copied to the project directory on the Windows machine:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/26-output.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-712\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/26-output.png\" alt=\"26-output\" width=\"804\" height=\"663\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/26-output.png 804w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/26-output-300x247.png 300w\" sizes=\"(max-width: 804px) 100vw, 804px\" \/><\/a><\/li>\n<li>As you have imported the RaspiCam project into Visual Studio, you can now use the Code Map window to explore the relations between its functions and fields used by them:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/27-codemap.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-713\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/27-codemap.png\" alt=\"27-codemap\" width=\"699\" height=\"720\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/27-codemap.png 699w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/27-codemap-291x300.png 291w\" sizes=\"(max-width: 699px) 100vw, 699px\" \/><\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to use the Raspberry Pi 2 camera from C++ programs developed with Visual Studio and VisualGDB.<\/p>\n","protected":false},"author":1,"featured_media":716,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[103,72,33,85],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/680"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=680"}],"version-history":[{"count":4,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/680\/revisions"}],"predecessor-version":[{"id":8188,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/680\/revisions\/8188"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media\/716"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=680"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}