Install and build OpenCV python From Source on Raspberry pi 4 and 3

Поділитися
Вставка
  • Опубліковано 11 гру 2024

КОМЕНТАРІ • 80

  • @index-zero
    @index-zero  2 роки тому +11

    OBS: for those who are getting error: No module named 'cv2'
    I think it's because there is no python2 installed anymore in raspberry pi, therefore opencv will not be installed properly.
    Solution:
    After you run sudo make install run this command: sudo cp -R /usr/local/lib/python3.9/site-packages/cv2/ /usr/local/lib/python3.9/dist-packages/
    Just check if you have the same python version otherwise just change it to your pythons version so for example if you have python3.7 installed change the python3.9 to python3.7.
    Let me know if this solve your problem.

    • @SunilKumar-qo2nb
      @SunilKumar-qo2nb 2 роки тому +1

      cp: cannot stat '/usr/local/lib/python3.7/site-packages/cv2/': No such file or directory
      after running the command sudo -R/usr.. I am getting this error
      I am not able to creat cv2 folder manually also in the path : /usr/local/lib/python3.7/site-packages (getting message as permission denied)
      Please reply

    • @index-zero
      @index-zero  2 роки тому +2

      @@SunilKumar-qo2nbrun this commend after you did everything in this video and if still there is not any folder called cv2 in /usr/local/lib/python3.7/site-packages so that means the opencv was not installed correctly and it can have many reason so I dont really know how to solve it. Otherwise you can install it from Pre-built Binaries by typing 'sudo apt-get install python3-opencv'.

    • @danifrii
      @danifrii 2 роки тому +1

      worked for me. Thank you

    • @040danukurnia8
      @040danukurnia8 2 роки тому +1

      its work

    • @boramawi
      @boramawi Рік тому

      That worked for me! Thanks Cheers! :)

  • @priyagujre3113
    @priyagujre3113 Рік тому +1

    Thank you!
    The compile process got stuck many times . It took more than 18hours for opencv to get installed( Rpi3b+, 1gb ram)
    I increased the swapsize to 4096.
    Kept GPU at 76. I used make -j4 command.
    Made sure that the board is well ventilated and not getting heated up.
    Also I used raspcontroller app to check if the download is still continuing or got stuck .
    I don't know if this makes sense, but it helped me.
    After 99% it took almost three hours to get the process completed.

  • @PatrickBateman32
    @PatrickBateman32 Рік тому +3

    Yo please help out at 63% it canceled and gave a long list of errors and whatnots but the main thing is [makefile:182: all] Error 2. Ive tried redoing the make command and that pip upgrade thing you said

  • @bgmistreamersmoments1835
    @bgmistreamersmoments1835 Рік тому +1

    i am getting error in make command that no target is sepcified and no makefile found

  • @badarali6550
    @badarali6550 2 роки тому +4

    Can it be install in Raspberry Pi 3 model B ram 1GB?

  • @vnpoka3020
    @vnpoka3020 3 роки тому +3

    thank you very much. but i spent 7 hours to install it. this is very long long time. it is not 2 3 hours . lmao

  • @SunilKumar-qo2nb
    @SunilKumar-qo2nb 2 роки тому +3

    Hello sir.. I am also getting the same error i.e.
    python3
    import cv2 as cv
    ModuleNot FoundError: No module named 'cv2'
    I followed exactly the same steps as mentioned in your doc. Please help as soon as possible.
    I am using Raspberry Pi 4 Model B 8GB

  • @oliverorwell3773
    @oliverorwell3773 3 роки тому +1

    I want to know how to install cvzone and tensorflow 2 on raspberry pi

  • @ilaydabalk8355
    @ilaydabalk8355 3 роки тому +3

    Hello everyone, firstly thank you for your explanatory video. I've a problem about installation of openCV to my raspberry pi 4 model - b,
    Problems that program gave me :
    make[2]: *** [modules/dnn/CMakeFiles/opencv_perf_dnn.dir/build.make:230: bin/opencv_perf_dnn] Error 1
    make[1]: *** [CMakeFiles/Makefile2:2238: modules/dnn/CMakeFiles/opencv_perf_dnn.dir/all] Error 2
    make: *** [Makefile:182: all] Error 2
    Are there anybody who have an idea to fix that problem, thanx

    • @amritraj7640
      @amritraj7640 2 роки тому

      Run that code again to fix. Same problem but worked for me

    • @Protias12
      @Protias12 Рік тому

      @@amritraj7640 I have run "make" again but the problem persists, do you have any other alternative solution?

  • @Vector-uz9sc
    @Vector-uz9sc 3 роки тому +2

    can i do the same for the raspberry pi zero w?

    • @index-zero
      @index-zero  3 роки тому +1

      Yeh I think it should work.

    • @sravanjosh1218
      @sravanjosh1218 3 роки тому

      @Vector5284 had it worked with rasp pi Zero W ?

  • @mrmoody915
    @mrmoody915 3 роки тому +1

    I keep getting cannot create directory 'build': File exists every time I input "cd ~opencv && mkdir build && cd build"

    • @index-zero
      @index-zero  3 роки тому

      Sounds like you already created a build folder so just type 'cd opencv/build'.

  • @wassimmodric6436
    @wassimmodric6436 9 місяців тому

    Is the raspberry pi 3 work good with openCV or i need to buy tje raspberry pi 4 ?

  • @syakirpro1929
    @syakirpro1929 3 роки тому +2

    Sir I have a question, I follow every step and it seems to be okey however. At 99% of /Desktop/opencv/build/ $ make , my desktop totally freeze. Hope you can help me sir thank you

    • @index-zero
      @index-zero  3 роки тому +1

      Sorry but I really don't know what is the problem :-( .

    • @syakirpro1929
      @syakirpro1929 3 роки тому +1

      Is okey sir thank you hehe

    • @daBAAAAM
      @daBAAAAM 3 роки тому

      @@syakirpro1929 Did you fix the problem? I have the same one

  • @oliverorwell3773
    @oliverorwell3773 3 роки тому +1

    Great video ❤❤

  • @fasel991
    @fasel991 2 роки тому +1

    When i write cmake ../ i got ( command not found) what is the solution please?

    • @hursitsahin864
      @hursitsahin864 Рік тому

      did you get any answer?

    • @arindamchakraborty9520
      @arindamchakraborty9520 Рік тому

      check if you are creating the folder ("Build") inside the opencv directory or not
      if not:
      $ cd opencv
      $ mkdir Build
      $ cd Build
      $ cmake ../

  • @gowtham-qj7qg
    @gowtham-qj7qg 3 роки тому +3

    it took 4 hours for me in pi 4

  • @solouniverse5252
    @solouniverse5252 3 роки тому +2

    Open CV 4 in raspberry Pi is that same method???
    Please reply

  • @qzorn4440
    @qzorn4440 Рік тому

    really wonderful OpenCV video. Would the installation be the same for an Orange Pi 800? Thank you.

  • @firmanagroni2012
    @firmanagroni2012 Рік тому +1

    why when in "make" it stops at 98 percent only

    • @mohalghaithi9873
      @mohalghaithi9873 Рік тому

      did u find a solution, I'm having the same problem

    • @Anor27
      @Anor27 Рік тому

      @@mohalghaithi9873 me too

    • @Sniper-rl3xq
      @Sniper-rl3xq Рік тому

      same afterv almost 11 hours

    • @gero29663
      @gero29663 Рік тому

      me too, any solution?

  • @tranthanh-wx5ps
    @tranthanh-wx5ps 3 роки тому +1

    thank you very much!

  • @mayorjed4719
    @mayorjed4719 3 роки тому +1

    Thank you!

  • @roni1422
    @roni1422 2 роки тому +1

    "make" operation takes a lot of time.It's about 44 percent and it started 12 hours ago. what i suposed to do?

    • @index-zero
      @index-zero  2 роки тому

      Try "make -j4", it will speed up the make process.

    • @roni1422
      @roni1422 2 роки тому

      @@index-zero I tried, now the make operation does not work. it wtirtes" no targets specified and no makefile found" and "command not found" . can you help me?

    • @roni1422
      @roni1422 2 роки тому

      @@index-zero I tried, now the make operation does not work. it wtirtes" no targets specified and no makefile found" and "command not found" . can you help me?

    • @index-zero
      @index-zero  2 роки тому +1

      @@roni1422 you have to run this command when you are in build folder, so when you are in opencv folder run cd build then run the make -j4

    • @roni1422
      @roni1422 2 роки тому +1

      @@index-zero The raspberry stucks at 90% when I use make-j4. do you know what can I do?

  • @yunusemrekoksal9481
    @yunusemrekoksal9481 2 роки тому +1

    i am getting this error how can i fix it
    (bash: cd: too many arguments)

    • @index-zero
      @index-zero  2 роки тому +1

      When you are getting this error?

    • @yunusemrekoksal9481
      @yunusemrekoksal9481 2 роки тому +1

      @@index-zero mkdir build

    • @index-zero
      @index-zero  2 роки тому

      Sorry I'm not sure why you are getting this error.

  • @Ber-rs6mq
    @Ber-rs6mq Рік тому

    Thank you very much

  • @imadeddarraz3247
    @imadeddarraz3247 3 роки тому +1

    thank you so much...

  • @manhhuynhquoc8349
    @manhhuynhquoc8349 2 роки тому +1

    What OS are you using?

    • @index-zero
      @index-zero  2 роки тому

      Windows

    • @toongvang1730
      @toongvang1730 2 роки тому

      ​@@index-zero Do you use raspberry Pi OS Lite(Legacy) or raspberry Pi OS (Legacy)?

  • @noureddineel-haryqy4941
    @noureddineel-haryqy4941 3 роки тому +1

    thank you

  • @truongvu9370
    @truongvu9370 3 роки тому +1

    thanks you, i did yet

  • @劉玄瑋
    @劉玄瑋 2 роки тому +2

    When I tape import cv2,I get this error
    RuntimeError: module compiled against API version 0xf but this version of numpy is 0xd
    Traceback (most recent call last):
    File "", line 1, in
    File "/home/pi/.local/lib/python3.9/site-packages/cv2/__init__.py", line 8, in
    from .cv2 import *
    ImportError: numpy.core.multiarray failed to import
    how I can fix it

    • @index-zero
      @index-zero  2 роки тому

      Did you run this command 'sudo apt-get install python3-dev python3-numpy'? Also try this command "pip install numpy --upgrade"

    • @reefstarnes839
      @reefstarnes839 2 роки тому

      @@index-zero I love you

    • @abdulrahmanalkubidh411
      @abdulrahmanalkubidh411 2 роки тому

      I did it in the terminal and worked for me but when i do it in thonny i still have the same problem pls help and reply

  • @zAbdullahKhan
    @zAbdullahKhan 3 роки тому +3

    Please always mention Raspberry Pi specs. I know it is Pi 4, but the memory is really a big concern when it comes to compiling and installing opencv, that is, if your Pi has low memory i.e. 2GB the chances are that it will freeze at some point and won't be able to install opencv eventually. BTW, what are your specs? Also, what version of Raspbian have you installed 32-bit or 64bit?

    • @index-zero
      @index-zero  3 роки тому +1

      Yeh you are right I had to mention it thank that you pointed it out.
      I have a Raspberry Pi 4 - 4GB, and also have installed a 32-bit Raspbian.

    • @tariqnajjar6589
      @tariqnajjar6589 2 роки тому

      the documentation says that it is for ubuntu .... 64bit
      how did it work with you with 32 bit?

  • @pipe4x
    @pipe4x 2 роки тому +1

    I ´ve follow all the steps along with the video and I keep getting an error in the las step, when you go to python to check the installation :
    python3
    import cv2 as cv
    ModuleNot FoundError: No module named 'cv2'
    do you know what is the problem? I am trying to instal in a raspberry pi3 model B+

    • @index-zero
      @index-zero  2 роки тому

      Did you install with sudo?

    • @JiaEnLimmmm
      @JiaEnLimmmm 2 роки тому

      Hi same issue as well! After sudo make install, i went to check it mention similar error as well

    • @JiaEnLimmmm
      @JiaEnLimmmm 2 роки тому

      Somehow issue is resolved when i ran sudo apt-get install python3-opencv

  • @siddharamdivate9710
    @siddharamdivate9710 2 роки тому +1

    Hey, I have installed opencv on my raspberry pi 3 , i can import opencv in terminal only but not in thonny python, if i try to run command import cv2 in thonny python, i'm getting this error " No module named cv2 " ,
    Please help me resolve this problem

    • @index-zero
      @index-zero  2 роки тому

      I have tried in my raspberry pi 4 and it works just fine so I dont know what is exactly the problem.

  • @jarifmizi2949
    @jarifmizi2949 2 роки тому +1

    I followed all of the instructions as it is .. but still to not working

    • @index-zero
      @index-zero  2 роки тому +1

      Did you try this:
      After you run sudo make install run this command: sudo cp -R /usr/local/lib/python3.9/site-packages/cv2/ /usr/local/lib/python3.9/dist-packages/
      Just check if you have the same python version otherwise just change it to your pythons version so for example if you have python3.7 installed change the python3.9 to python3.7.

  • @easterncaravan
    @easterncaravan 3 роки тому +1

    successfully install in raspbarian os