LabVIEW supports pallete for calling function from python. Do I need to develop 3 seperate functions each for initializing, capturing and closing? Using OpenCV in python for accessing directshow based usb cameras.
If I create 3 seperate functions, do I need to include them in a same python script? As if I am using while loop for capturing function, functions written after that wont possibly be called. If I keep them in different python scripts, will it recognize that the camera is operating in a same session?
Why does subsequent functions does not recognize 'cam'?
import cv2
import math
import os
camname = -1
img_name = "sample"
filepath = r"C:\Users\Public"
message = "sampler"
caminitok = False
inierror = False
def caminit(camname):
cam = cv2.VideoCapture(camname)
if not (cam.isOpened()):
return inierror == True
else:
return inierror == False
def camcapture(img_name, filepath, caminitok):
if caminitok == True:
ret, frame = cam.read()
os.chdir(filepath)
cv2.imwrite(img_name, frame)
def camclose():
cam.release()