Sep 14, 2015

[ Raspberry Pi2 ] OpenCV using Picam 2



1. Create new Foler.

We will create and use new folder.
  1. cd
  2. mkdir camcv
  3. cd camcv
  4. cp -/opt/vc/userland/host_applications/linux/apps/raspicam/* .
  5. mv RaspiStill.c camcv.c

and rename raspistill.c to camcv.c (This file is still-shot file) 

Editing cmakelists.txt 

  1. sudo nano CMakeLists.txt

Recommend Delete all text and copy below text.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
cmake_minimum_required(VERSION 2.8)
 project(camcv)
 SET(COMPILE_DEFINITIONS -Werror)
include_directories(/opt/vc/userland/host_applications/linux/libs/bcm_host/include)
 include_directories(/opt/vc/userland/interface/vcos)
 include_directories(/opt/vc/userland)
 include_directories(/opt/vc/userland/interface/vcos/pthreads)
 include_directories(/opt/vc/userland/interface/vmcs_host/linux)
 include_directories(/opt/vc/userland/interface/khronos/include)
 include_directories(/opt/vc/userland/interface/khronos/common)
 include_directories(/home/pi/camcv/)
 include_directories(/home/pi/camcv/gl_scenes/)
 include_directories(/home/pi/camcv/libfacerec/include/)
add_executable(camcv RaspiCamControl.c RaspiCLI.c RaspiPreview.c camcv.c RaspiTex.c RaspiTexUtil.c gl_scenes/teapot.c gl_scenes/models.c gl_scenes/square.c gl_scenes/mirror.c gl_scenes/sobel.c gl_scenes/yuv.c tga.c )
target_link_libraries(camcv /opt/vc/lib/libmmal_core.so /opt/vc/lib/libmmal_util.so /opt/vc/lib/libmmal_vc_client.so /opt/vc/lib/libvcos.so /opt/vc/lib/libbcm_host.so /opt/vc/lib/libGLESv2.so /opt/vc/lib/libEGL.so libpthread.so libm.so)
cs

cmake
  1. cmake .




make
  1. sudo make


Run~!!
  1. ./camcv -1000

Maybe picam's led turn on about 1 sec.

2. Save to jpg file.

changing camcv.c
  1. sudo nano camcv.c

Searching 'default_status(&state);' and add below line ' state.filename=”foobar.jpg”; '
  1. state.filename=”foobar.jpg;

cmake . and make


Run
  1. ./camcv -1000

picam turn on led.

Check file.
  1. ls


P.S If you see stray error 

If you see above error, change to ANSI text mode.


No comments:

Post a Comment