0

I'm trying to get opencv2 working on a Raspberry PI with a NOIR camera module. As I understand it Opencv doesn't work natively with the camera module; so I'm following this link to try and get it working.

I've installed Opencv on the PI, and I think thats working, but just need it to work with the camera.

When I get to step 3 in the above link, which suggests I navigate to the /opt/vc folder and type:

sed -i ‘s/if (DEFINED CMAKE_TOOLCHAIN_FILE)/if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)/g’ makefiles/cmake/arm-linux.cmake 

I get the error message:

-bash: syntax error near unexpected token `('

1) Could someone please explain what the above command does?

2) Why might I get this error?

3) Does the folder structure matter? When I downloaded the source files from github, it was in the format userland-master/userland-master/then_all_the_files so I took all_the_files and placed them in the /opt/vc/ folder.

  • Now you have it solved I can explain what the command does. sed the Stream EDitor takes the input from makefiles/cmake/arm-linux.cmake and applies the substitution command (thats the "s" in front of the "/"). This uses everything up until the second "/" as the FIND and everything after that "/" until the last "/" as the REPLACE (please note that these are treated as regular expressions). The last "g" is the global flag indicating that all occurrences and not just the first one found on each line are replaced. – rob Feb 16 '15 at 13:10
2

Oh dear!

I didn't read the comments, the first comment suggested i chainge the type of quotation marks, and bingo it worked, Sorry!

This worked:

sudo sed -i 's/if (DEFINED CMAKE_TOOLCHAIN_FILE)/if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)/g' makefiles/cmake/arm-linux.cmake

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.