Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Importing cv2 through VB for web app

I have a functional python script that performs facial recognition using dlib and opencv.

My problem: as soon as I run the python script through VB as a web app, I receive an error "System.Exception: 1".

I have isolated the problem; the error only occurs when I include the line "import cv2" in the python script being executed.

Once again, this only happens when I run the python script through VB. When I run the python script through Spyder or command prompt it runs perfectly. I have successfully installed OpenCV in the the environment that VB is using, and I have reinstalled the module in an attempt to solve the issue, but to no avail.

I have run out of ideas as to what could cause this problem. Any advice on this would be greatly appreciated.

Importing cv2 through VB for web app

I have a functional python script that performs facial recognition using dlib and opencv.

My problem: as soon as I run the python script through VB as a web app, I receive an error "System.Exception: 1".

I have isolated the problem; the error only occurs when I include the line "import cv2" in the python script being executed.

Once again, this only happens when I run the python script through VB. When I run the python script through Spyder or command prompt it runs perfectly. I have successfully installed OpenCV in the the environment that VB is using, and I have reinstalled the module in an attempt to solve the issue, but to no avail.

VB code running Python script with image path as an argument:

Dim Processtask As New System.Diagnostics.Process()
Processtask.StartInfo.FileName = "cmd.exe"
Processtask.StartInfo.Arguments = "/c python " + path.ToString + " " + ImageURL.ToString
Processtask.StartInfo.UseShellExecute = False
Processtask.StartInfo.RedirectStandardOutput = True
Processtask.StartInfo.RedirectStandardError = True
Processtask.StartInfo.CreateNoWindow = True
Processtask.Start()
Processtask.WaitForExit()
output = Processtask.StandardOutput.ReadToEnd()

Python code snippet receiving image path:

import sys 
import cv2
if __name__ == "__main__":
    im = str(sys.argv[1])
print(im)

I have run out of ideas as to what could cause this problem. Any advice on this would be greatly appreciated.

Importing cv2 through VB for web app

I have a functional python script that performs facial recognition using dlib and opencv.

My problem: as soon as I run the python script through VB as a web app, I receive an error "System.Exception: 1".

I have isolated the problem; the error only occurs when I include the line "import cv2" in the python script being executed.

Once again, this only happens when I run the python script through VB. When I run the python script through Spyder or command prompt it runs perfectly. I have successfully installed OpenCV in the the environment that VB is using, and I have reinstalled the module in an attempt to solve the issue, but to no avail.

VB code running Python script with image path as an argument:

Dim Processtask As New System.Diagnostics.Process()
Processtask.StartInfo.FileName = "cmd.exe"
Processtask.StartInfo.Arguments = "/c python " + path.ToString + " " + ImageURL.ToString
Processtask.StartInfo.UseShellExecute = False
Processtask.StartInfo.RedirectStandardOutput = True
Processtask.StartInfo.RedirectStandardError = True
Processtask.StartInfo.CreateNoWindow = True
Processtask.Start()
Processtask.WaitForExit()
output = Processtask.StandardOutput.ReadToEnd()

Python code snippet receiving image path:

import sys 
import cv2
if __name__ == "__main__":
    im = str(sys.argv[1])
print(im)

I have run out of ideas as to what could cause this problem. Any advice on this would be greatly appreciated.

EDIT

I managed to find the full error message which reads as follows:

System.Exception: System.IO.StreamReader System.InvalidOperationException: Process has exited, so the requested information is not available. at System.Diagnostics.Process.EnsureState(State state) at System.Diagnostics.Process.get_ProcessName() at System.Diagnostics.Process.ToString()

Importing cv2 through VB for web app

I have a functional python script that performs facial recognition using dlib and opencv.

My problem: as soon as I run the python script through VB as a web app, I receive an error "System.Exception: 1".

I have isolated the problem; the error only occurs when I include the line "import cv2" in the python script being executed.

Once again, this only happens when I run the python script through VB. When I run the python script through Spyder or command prompt it runs perfectly. I have successfully installed OpenCV in the the environment that VB is using, and I have reinstalled the module in an attempt to solve the issue, but to no avail.

VB code running Python script with image path as an argument:

Dim Processtask As New System.Diagnostics.Process()
Processtask.StartInfo.FileName = "cmd.exe"
Processtask.StartInfo.Arguments = "/c python " + path.ToString + " " + ImageURL.ToString
Processtask.StartInfo.UseShellExecute = False
Processtask.StartInfo.RedirectStandardOutput = True
Processtask.StartInfo.RedirectStandardError = True
Processtask.StartInfo.CreateNoWindow = True
Processtask.Start()
Processtask.WaitForExit()
output = Processtask.StandardOutput.ReadToEnd()

Python code snippet receiving image path:

import sys 
import cv2
if __name__ == "__main__":
    im = str(sys.argv[1])
print(im)

I have run out of ideas as to what could cause this problem. Any advice on this would be greatly appreciated.

EDIT

I managed to find the full error message which reads as follows:

System.Exception: System.IO.StreamReader
System.InvalidOperationException: Process has exited, so the requested information is not available.
at System.Diagnostics.Process.EnsureState(State state) at System.Diagnostics.Process.get_ProcessName()
at System.Diagnostics.Process.ToString()

System.Diagnostics.Process.ToString()