Global Name CV2 is not defined
I am not a coder by any means so if I fail to present enough information for my question to make sense please let me know.
I am trying to display images one after the other selected from a directory that is being continually populated, and the image is being selected by a variable read from a plc. I have installed opencv using the prebuilt librabries method here: https://opencv-python-tutroals.readth...
I checked the installation
import numpy
import cv2
Print cv2.__version__
3.2.0
So everything looks good so far.
Sys info for python:
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on win32
OS: Windows 7 64bit
pip freeze
configparser==3.5.0
cpppo==3.9.7
cycler==0.10.0
functools32==3.2.3.post2
greenery==2.1
ipaddress==1.0.18
matplotlib==2.0.2
numpy==1.13.1
olefile==0.44
opencv==1.0.1
Pillow==4.2.1
pycomm==1.0.8
pyparsing==2.2.0
pyreadline==2.1
python-dateutil==2.6.1
pytz==2017.2
six==1.10.0
Wand==0.4.4
Code for the small project
import sys
import numpy as np
from cv2 import *
from cpppo.server.enip.get_attribute import proxy_simple
import time
import os
import threading
host = "###.###.###.###"
def whatever():
threading.Timer(2, whatever).start()
x, = proxy_simple(host).read(( "CPID"))
ImagePath = os.getcwd() + "\\" + str(x) + ".bmp"
img = cv2.imread('ImagePath')
cv2.imshow('imagewindow', img)
cv2.waitKey(0)
whatever()
Output of windows powershell:
Traceback (most recent call last):
File "opencv.py", line 20, in <module>
whatever()
File "opencv.py", line 17, in whatever
img = cv2.imread('ImagePath')
NameError: global name 'cv2' is not defined
I am wondering if I have the cv2 module not installed properly, but my coding skills are not good enough for me to understand. Do I need to reinstall it, or am I using cv2 improperly?
Thank you for your help.