OpenCV closes my FreeCAD

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: OpenCV closes my FreeCAD

Post by looo »

You can try to add the install-dir to the path:

Code: Select all

import sys
sys.path.append("/usr/local/python/2.7")
import cv2
But the proper solution would be to install to a directory which is already in the sys.path eg.: '/usr/local/lib/python2.7/dist-packages'
Leatherman
Posts: 155
Joined: Thu Feb 02, 2017 2:49 pm

Re: OpenCV closes my FreeCAD

Post by Leatherman »

looo wrote:You can try to add the install-dir to the path:

Code: Select all

import sys
sys.path.append("/usr/local/python/2.7")
import cv2
But the proper solution would be to install to a directory which is already in the sys.path eg.: '/usr/local/lib/python2.7/dist-packages'
Ok that worked:

Code: Select all

import sys
>>> sys.path.append("/usr/local/python/2.7")
>>> import cv2
>>> 
But this didn't:

Code: Select all

freecadcmd-daily
FreeCAD 0.17, Libs: 0.17R10885 (Git)
(c) Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2017
  #####                 ####  ###   ####  
  #                    #      # #   #   # 
  #     ##  #### ####  #     #   #  #   # 
  ####  # # #  # #  #  #     #####  #   # 
  #     #   #### ####  #    #     # #   # 
  #     #   #    #     #    #     # #   #  ##  ##  ##
  #     #   #### ####   ### #     # ####   ##  ##  ##

[FreeCAD Console mode <Use Ctrl-D (i.e. EOF) to exit.>]
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named cv2
>>> 
It seems that you very well know what's going on, could you kindly finish this thread? ;)
How are we getting OpenCV now running in FreeCAD?

Thanks,
Andre
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: OpenCV closes my FreeCAD

Post by looo »

No, I really don't know why it installs to a wrong location. Just had a look at the conda-recipe for open-cv:
https://github.com/conda-forge/opencv-f ... ld.sh#L105

maybe you can try to run cmake with this option:

Code: Select all

cmake .. -DPYTHON_PACKAGES_PATH=/usr/local/lib/python2.7/dist-packages
sudo make install
ps.:
But this didn't:
do the same in FreeCAD:

Code: Select all

import sys
sys.path.append("/usr/local/python/2.7")
import cv2
Leatherman
Posts: 155
Joined: Thu Feb 02, 2017 2:49 pm

Re: OpenCV closes my FreeCAD

Post by Leatherman »

looo wrote:No, I really don't know why it installs to a wrong location. Just had a look at the conda-recipe for open-cv:
https://github.com/conda-forge/opencv-f ... ld.sh#L105

maybe you can try to run cmake with this option:

Code: Select all

cmake .. -DPYTHON_PACKAGES_PATH=/usr/local/lib/python2.7/dist-packages
sudo make install
ps.:
But this didn't:
do the same in FreeCAD:

Code: Select all

import sys
sys.path.append("/usr/local/python/2.7")
import cv2
You closed the thread! :lol:

Code: Select all

freecadcmd-daily
FreeCAD 0.17, Libs: 0.17R10885 (Git)
(c) Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2017
  #####                 ####  ###   ####  
  #                    #      # #   #   # 
  #     ##  #### ####  #     #   #  #   # 
  ####  # # #  # #  #  #     #####  #   # 
  #     #   #### ####  #    #     # #   # 
  #     #   #    #     #    #     # #   #  ##  ##  ##
  #     #   #### ####   ### #     # ####   ##  ##  ##

[FreeCAD Console mode <Use Ctrl-D (i.e. EOF) to exit.>]
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named cv2
>>> import sys
>>> sys.path.append("/usr/local/python/2.7")
>>> import cv2
>>> 
Which leaves us with the idea that OpenCV 2.4.13 works with FreeCAD and the latest Version of CV2 not. If you have all the dependencies ready you can simply follow the instructions from Microelly2 otherwise here you find the list and instructions as well:
https://codegists.com/code/opencv-2.4.13-documentation/
Why it's installed on the wrong place seems to be strange but may be not too important at the moment, I guess or do you think I should try the new cmake code?

Thanks for everybody's help and hopefully I don't need to add something in this thread anymore! :P
Post Reply