MMAL library and raspivid/raspistill source code are found in Userland folder (@GitHub, here). First of all, we need to compile the whole package before doing anything else with OpenCV.
- get source code (zip file) here : https://github.com/raspberrypi/userland
- unzip the file and copy the directory under /opt/vc
- go to opt/vc and type : sed -i ‘s/if (DEFINED CMAKE_TOOLCHAIN_FILE)/if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)/g’ makefiles/cmake/arm-linux.cmake
- create a build directory and compile (it takes a while)
sudo mkdir build
cd build
sudo cmake -DCMAKE_BUILD_TYPE=Release ..
sudo make
sudo make install
Binary should be under /opt/vc/bin
Go to /opt/vc/bin and test one file typing : ./raspistill -t 3000
At this stage, you should be able to modify this software to include OpenCV calls. Congratulation ! Now, all nexts steps are piece of cakes….
Hi – I’m getting the following error message. I’m guessing this means that I don’t have some of the environment variables set?
pi@raspberrypi /opt/vc $ sed -i ‘s/if (DEFINED CMAKE_TOOLCHAIN_FILE)/if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)/g’ makefiles/cmake/arm-linux.cmake
-bash: syntax error near unexpected token `(‘
It worked if I used
sed -i ‘s/if (DEFINED CMAKE_TOOLCHAIN_FILE)/if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)/g’ makefiles/cmake/arm-linux.cmake
from http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=43990, post 6. It appears to be the types of quotes. They appear similar on this page but in a text editor on my Mac the single quotes are at a different angle.
I don’t see that sixth post. I can do the backtick ` but not the other part of the single quote that points in the other direction. No idea where that’s hiding in my standard US-EN keyboard.
Addendum: I was able to skip the step using sed by manually editing makefiles/cmake/arm-linux.cmake and adding the “NOT” before “DEFINED”
Pingback: OpenCV and Pi Camera Board ! | Think RPI
Sorry, I do not understand how to access /opt/vc
Can you please explain how?
cd /opt/vc
This directory should exist on your rpi.
If you’ve followed step 2 and obtained an unzipped userland-master directory, and you then copy the userland-master tree under /opt/vc, giving yourself /opt/vc/userland-master, then you will want to cd to /opt/vc/userland-master prior to issuing the sed command, yes?
Also, there appears to be only one line, line 3, in the userland-master/makefiles/cmake/arm-linux.cmake file that needs to be modified, so rather than using the sed script if it gives you trouble, you might just want to go into the file and add the word NOT prior to DEFINED on line 3.
Question on that. In Step 2 I’m unable to copy the file into the /opt/vc directory. It doesn’t allow me “Permission Denied”. I’ve tried both through Terminal and just Drag and drop.
Any suggestions?
I am facing the same problem … unable to copy to /opt/vc. i type the following command
cp /home/pi/userland-master /opt/vc
i get
cp: omitting directory ‘/home/pi/userland-master’
and when i check in /opt/vc i dont find anything.
can anyone suggest me whats wrong?
Hey problem is solved. type the code
sudo cp -R /home/pi/userland-master /opt/vc
this help your task done.
Thanks Kevin
You can skip this step completely. All the required libraries are already in raspbian under /opt/vc/lib and most include files (except the mmal ones) are already available under /opt/vc/include. See my comment under step 3 for details how to compile camcv.
i cannot copy the folder to opt/vc
it says i dont have the right permission
u will have to do it via terminal
How do u do it on terminal?
Hello nox, did you figure out how to copy the files to /opt/vc folder? Please help me with this.
I figured out the second step of moving files. It is as follows
1) download it in your laptop and unzip it
2) copy that folder in the /home/pi section by using any of the method(i used file-zilla)
3) go to terminal and type sudo su
4) then type (take care of the spaces between the codes, else destination won’t be found.
sudo cp -R /home/pi/userland-master /opt/vc
thanks a lot everyone.
Change to Super User for write access to opt/vc and get source from git
sudo su
cd /opt/vc
git clone git://github.com/raspberrypi/userland.git
I found I had to define FULL_RES_PREVIEW_FRAME_RATE_NUM and FULL_RES_PREVIEW_FRAME_RATE_DEN in RaspiPreview.h before the sample apps would build… hope that’s useful?
Hi, I got an error while executing sudo make:
[ 95%] Building C object host_applications/linux/apps/raspicam/CMakeFiles/raspistill.dir/RaspiStill.c.o
/opt/vc/userland-master/host_applications/linux/apps/raspicam/RaspiStill.c: In function ‘create_camera_component’:
/opt/vc/userland-master/host_applications/linux/apps/raspicam/RaspiStill.c:692:42: error: ‘FULL_RES_PREVIEW_FRAME_RATE_NUM’ undeclared (first use in this function)
/opt/vc/userland-master/host_applications/linux/apps/raspicam/RaspiStill.c:692:42: note: each undeclared identifier is reported only once for each function it appears in
/opt/vc/userland-master/host_applications/linux/apps/raspicam/RaspiStill.c:693:42: error: ‘FULL_RES_PREVIEW_FRAME_RATE_DEN’ undeclared (first use in this function)
make[2]: *** [host_applications/linux/apps/raspicam/CMakeFiles/raspistill.dir/RaspiStill.c.o] Fehler 1
make[1]: *** [host_applications/linux/apps/raspicam/CMakeFiles/raspistill.dir/all] Fehler 2
make: *** [all] Fehler 2
does anyone knows what I have to do to get this build?
I get error cmake: command not found
any help would be appreciated!
Anthony
sudo apt-get install cmake
Below is what I did:
root@raspberrypi:/opt/vc# ls
bin include lib master.zip sbin src userland-master
root@raspberrypi:/opt/vc# cd userland-master/
root@raspberrypi:/opt/vc/userland-master# sed -i ‘s/if (DEFINED CMAKE_TOOLCHAIN_FILE)/if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)/g’ makefiles/cmake/arm-linux.cmake
root@raspberrypi:/opt/vc/userland-master# sudo mkdir build
root@raspberrypi:/opt/vc/userland-master# cd build
root@raspberrypi:/opt/vc/userland-master/build# sudo cmake -DCMAKE_BUILD_TYPE=Release ..
sudo: cmake: command not found
you have to install cmake throught this command:
sudo apt-get install cmake
is apt-get install cmake needed? or should it already be there?
hello.
If you’re running an Apple 2+/2e/2c, type “poke 33,33”, then “load cmake” and then “run”.
if you’re working on a raspberry, read the step 3 of my previous post Magic Mirror (install software)
got it Thanks, An hoping to use the pi for finding speed signs through the window of a car (made an android app, fps is 5 need faster)
Hello, i go to step 4 and met a problem. when execute “sudo cmake -DCMAKE_BUILD_TYPE=Release ..” , an error (“CMAKE_TOOLCHAIN_FILE not defined”) occured, I worked on it whole night still cant find solution. Need helps, thx
Same problem with you. Didn’t figure it out neither.
I think I solved that problem. Just follow the error, use this “sudo cmake -DCMAKE_BUILD_TYPE=Release .. -DCMAKE_TOOLCHAIN_FILE=toolchain_file.cmake”.
Hope it helps.
it says command not found for cmake
Hello all, i made it to step 3 and got this error…
root@raspberrypi:/opt/vc/userland-master# sed -i ‘s/if (DEFINED CMAKE_TOOLCHAIN_FILE)/if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)/g’ makefiles/cmake/arm-linux.cmake
bash: syntax error near unexpected token `(‘
root@raspberrypi:/opt/vc/userland-master#
You should make a space between ‘-i’ and ‘s’, ie., ‘ sed -i `s/if ~~~’ .
I am using Pidora. Will this code work on this OS? Thanks.
not running
sed -i `s/if (DEFINED CMAKE_TOOLCHAIN_FILE)/if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)/g´ makefiles/cmake/arm-linux.cmake
>
>
>
>
>
>
help please
Hi I tried to install this system but I have a problem when I try to run
sed -i `s/if (DEFINED CMAKE_TOOLCHAIN_FILE)/if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)/g´ makefiles/cmake/arm-linux.cmake
>
>
>
>
>
>
stays at the prompt with the symbols> when you press whatever
I can do it as well?
thanks
same problem
someone help you
Thanks!
Pingback: Compiling raspistill | An external memory dump
Step 3 is no longer necessary with the latest version on github.
You still have to do the
$ sudo apt-get install cmake
step described in the comments.
And step 4 is just typing ‘build’
Hi,
I think the step 3 should be
go to opt/vc/userland and type : sed -i ‘s/if (DEFINED CMAKE_TOOLCHAIN_FILE)/if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)/g’ makefiles/cmake/arm-linux.cmake
When I typed: sed -i ‘s/if (DEFINED CMAKE_TOOLCHAIN_FILE)/if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)/g’ makefiles/cmake/arm-linux.cmake
It said: couldn’t open temporary file makefiles/cmake/seduMkbNy: Permission denied.
How could I solve it???
Thanks!
you should use sudo
memory note: “go to opt/vc and type : sed -i ‘s/if (DEFINED CMAKE_TOOLCHAIN_FILE)/if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)/g’ makefiles/cmake/arm-linux.cmake”
is under /opt/vc/userland NOT /opt/vc
When I run the cmake command it shows that cMakelists.txt doesn’t exist. what could be the error?
could someone help, I am getting the same error
you are probably in the wrong folder (you probably have the following structure: /opt/vc/userland-master). Try:
cd /opt/vc/userland-master
sudo mkdir build
cd build
sudo cmake -DCMAKE_BUILD_TYPE=Release ..
sudo make
sudo make install
HI,all
after 2nd step when i tried doing 3rd this is the error i got .
pi@raspberrypi /opt/vc $ sed -i ‘s/if (DEFINED CMAKE_TOOLCHAIN_FILE)/if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)/g’ makefiles/cmake/arm-linux.cmake
bash: syntax error near unexpected token `(‘
how to solve it ? any help???
use ‘ for ‘s g’
not `
Hello Chetan, could you please help me with the second step I.e. to copy the file into the opt/vc folder.
Hi there, I would like to subscrribe for this webdite to get most recent updates, therefore here can i do
it please help.
Your explanations really give me a head ache.
🙂
it’s a part of C-coder’s life…
The tutorial is not clear, could you please make it a bit more clear?
On step 4…
pi@raspberrypi /opt/vc/build $ sudo cmake -DCMAKE_BUILD_TYPE=Release ..
CMake Error at CMakeLists.txt:16 (include):
include could not find load file:
makefiles/cmake/global_settings.cmake
CMake Error at CMakeLists.txt:17 (include):
include could not find load file:
makefiles/cmake/arm-linux.cmake
CMake Error at CMakeLists.txt:18 (include):
include could not find load file:
makefiles/cmake/vmcs.cmake
CMake Error at CMakeLists.txt:58 (add_subdirectory):
add_subdirectory given source “interface/vcos” which is not an existing
directory.
CMake Error at CMakeLists.txt:59 (add_subdirectory):
add_subdirectory given source “interface/vmcs_host” which is not an
existing directory.
CMake Error at CMakeLists.txt:60 (add_subdirectory):
add_subdirectory given source “interface/vchiq_arm” which is not an
existing directory.
CMake Error at CMakeLists.txt:61 (add_subdirectory):
add_subdirectory given source “interface/khronos” which is not an existing
directory.
CMake Error at CMakeLists.txt:66 (add_subdirectory):
add_subdirectory given source “interface/mmal” which is not an existing
directory.
CMake Error at CMakeLists.txt:77 (add_subdirectory):
add_subdirectory given source “middleware/openmaxil” which is not an
existing directory.
CMake Error at CMakeLists.txt:91 (add_subdirectory):
add_subdirectory given source “interface/usbdk” which is not an existing
directory.
CMake Error at CMakeLists.txt:111 (add_subdirectory):
add_subdirectory given source “host_applications/linux” which is not an
existing directory.
— Configuring incomplete, errors occurred!
How to solve this????
I solve the problem when i copy the folder userland-master do the /opt/vc.
Now I can compile, make, and make install.
When i go to /opt/vc/bin and type: ./raspistill -t 3000
i receive the error:
pi@raspberrypi /opt/vc/bin $ ./raspistill -t 3000
mmal: Argument is invalid
How to solve this?
Pedro how did you copy the userland folder into the opt/vc, please help me with this
Also seeing the:
mmal: Argument is invalid
message, is this an issue?
pi@raspberrypi /opt/vc/bin $ sudo ./raspistill -t 3000
mmal: mmal_vc_component_create: failed to create component ‘vc.ril.camera’ (1:ENOMEM)
mmal: mmal_component_create_core: could not create component ‘vc.ril.camera’ (1)
mmal: Failed to create camera component
mmal: main: Failed to create camera component
mmal: Camera is not detected. Please check carefully the camera module is installed correctly
i use a playstation cam
hello, I download the zip file but not from the command line , I unzipped it is ok ,but now I don’t know how to copy the directory in /opt/vc may anyone help me please ?
MMAL library and raspivid/raspistill source code are found in Userland folder (@GitHub, here). First of all, we need to compile the whole package before doing anything else with OpenCV.
get source code (zip file) here : https://github.com/raspberrypi/userland
unzip the file and copy the directory under /opt/vc
open a terminal and type : sudo apt-get install cmake
go to opt/vc and type : sed -i ‘s/if (DEFINED CMAKE_TOOLCHAIN_FILE)/if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)/g’ userland-master/makefiles/cmake/arm-linux.cmake
cd userland-master
// create a build directory and compile (it takes a while)
sudo mkdir build
cd build
sudo cmake -DCMAKE_BUILD_TYPE=Release ..
sudo make
sudo make install
Binary should be under /opt/vc/bin
Go to /opt/vc/bin and test one file typing : ./raspistill -t 3000
At this stage, you should be able to modify this software to include OpenCV calls. Congratulation ! Now, all nexts steps are piece of cakes….
go to opt/vc and type : sed -i ‘s/if (DEFINED CMAKE_TOOLCHAIN_FILE)/if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)/g’ makefiles/cmake/arm-linux.cmake,hi,when i m doing this sed report error: cant read makefiles/cmake/arm-linux.cmake.
i have a problem
Could anyone help me! Thanks so much!
/opt/vc/build# sudo make
make:*** No targets specified and no makefile found. Stop.
I can’t copy the directory under /opt/vc. Please help?
I am facing the same problem it says omitting directory.
Hi
To copy from your download folder to the VC folder use:
sudo mv /home/pi/Downloads/userland-master /opt/vc
Im a complete noob at the Raspberry Pi. Im unable to copy the files into the directory /opt/vc. It says i don’t have permission. Someone mentioned that i have to move them via terminal. Although I’m not sure what the code is for that. What i type exactly.
James, I’m also complete noob at RPi, but believe me, I read all these comments and managed to make this work 😀 it does take a few hours if you never worked on RPi (like me), so don’t give up so soon 😉
You have to go to the directory that you have your files (e.g. /home/pi/Downloads) and type in the terminal:
sudo cp -R userland /opt/vc
It will really work!
Hi I have a problem on STEP3. I write that command –
sed -i ‘s/if (DEFINED CMAKE_TOOLCHAIN_FILE)/if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)/g’ makefiles/cmake/arm-linux.cmake
and it wrote me back
bash: syntax error near unexpected token `(‘
..yes I have tried every options that many of they write here, but no one was good…please help!! 🙂
I found this is caused by copying and pasting the command into my putty session, just replace the two slanted single quotes or copy and past the below
sed -i ‘s/if (DEFINED CMAKE_TOOLCHAIN_FILE)/if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)/g’ makefiles/cmake/arm-linux.cmake
bash: syntax error near unexpected token `(‘ on STEP3, please help!
Pingback: Kubernetes, Docker, Raspistill,... - Tongfamily
okay. I see most people are having troubles with /opt/vc step and the step 3 .
first understand what the steps actually mean. the opt/vc step is basically trying to paste the Userland-master folder under the opt/vc folder. but this is no drag drop job. it has to be done via the terminal. you’ll again face a problem because we do not have the necessary permissions. so now try the same command using SUDO. sudo basically makes the command to break thru all necessary permissions.
same needs to be done with the steps 3.
the step 3 uses the sed command which with a little googling will tell you its a Stream Edit command. so basically it looks for a stream of line that says “DEFINED CMAKE_TOOLCHAIN_FILE” and changes it to ” NOT DEFINED CMAKE_TOOLCHAIN_FILE”.
again this cant be done by opening the file and editing it. why? permissions. we cant right click and change the permissions as well. this has to be done via the terminal with the prefix SUDO. and before using this command the author states to go to the directory /opt/vc. but this forgets the fact that the actual file intended to be changed is in the Userland-master folder. so first go to /opt/vc/Userland-master then apply the command with the prefix SUDO. and check to ensure the change.
hope this helps!
Hello, I recently purchased the rasppi and was trying the face recognition for my project.
I tired moving the git hub file using the following ways
1) changing to super user and then transferring
sudo su
cd /opt/vc
git clone git://github.com/raspberrypi/userland.git
Error: no such file or directory
2) using the sudo MV command
sudo mv /home/pi/Downloads/userland-master /opt/vc
Error: missing file destination
3) using filezilla
Error: no such file or directory
Any sort of help will be highly appreciated!
Thanking you in advance
Go to the directory of userland (in your case /home/pi/Downloads) and type in the terminal:
sudo cp -R userland-master /opt/vc
It works! 🙂
Hi. I am not able to find the source code files mentioned here
get source code (zip file) here : https://github.com/raspberrypi/userland
or do i need to download the complete folder as zip?
You need to download the complete folder as zip
Hi, First, thnks for the tutorial. Second, When I run “./raspistill -t 3000”, appear this: “./raspistill: error while loading shared libraries: libbrcmGLESv2.so: cannot open shared object file: No such file or directory”. Can anyone help me? Thanks
When I try to download the zip file from the given address using wget -O all I get back is an empty zip file, I can see there is no error with the page – is there something I need to append to the link?
Hi, for those who have a problem to run the sed command, it is necessary to replace the characters ” ‘ ” by characters (key 4 ‘ and {seen on the keyboard)
it is also noted in the tutorial “Go to / opt / vc / bin and test one file typing: ./raspistill -t 3000”.
Question: what result should we get on the screen? Can you describe an example? Thank you