Ask Your Question
0

I got this error "Failed to excute script camera". [closed]

asked 2019-03-21 00:04:48 -0500

Son Le gravatar image

updated 2019-03-21 11:53:09 -0500

supra56 gravatar image

Hello fellows, I have problem with building python code that has opencv imported in it, the error message when I run app is "Failed to excute script camera" (it is a desktop app). Below is my code, can you try to build it as exe file and run?

import cv2
cap = cv2.VideoCapture(0)
while(True):
    ret, frame = cap.read()
    rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2BGRA)
    cv2.imshow('frame', rgb)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        out = cv2.imwrite('capture.jpg', frame)
        break
cap.release()
cv2.destroyAllWindows()

Thank in advance!!!!!!!!!!

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by berak
close date 2019-03-22 01:53:50.050666

Comments

the code you show cannot throw the error in the title, so there must be more / something else ?

how do you actually try to run it ?

berak gravatar imageberak ( 2019-03-21 02:12:58 -0500 )edit

I meant after building the code and run the application it shows that error. Can you try to build that code i pasted above?

Son Le gravatar imageSon Le ( 2019-03-21 02:29:44 -0500 )edit
  • "building the code" -- what does it mean exactly ? (python is a interpreted language, it does not "build" anything)
  • "run the appliication" -- again , which "application", and how, exactly ?
berak gravatar imageberak ( 2019-03-21 02:34:22 -0500 )edit

I have that code above and now I use PyInstaller to convert it to .exe file to run it on Windows. Application in my opinion means the app (.exe file) created after converting.

Son Le gravatar imageSon Le ( 2019-03-21 02:44:01 -0500 )edit

opencv is not in the list

LBerger gravatar imageLBerger ( 2019-03-21 03:12:42 -0500 )edit

@Son Le -- there are a couple of posts, trying to use PyInstaller -- none of them with any success.

do you absolutely have to use it ? it looks like an unnessecary complication (since you also seem to be quite new to all of this)

berak gravatar imageberak ( 2019-03-21 03:40:46 -0500 )edit

What I need is to convert my code to .exe file with opencv included. I can try other but I dont know anything else but PyInstaller. Do you have any suggestion?

Son Le gravatar imageSon Le ( 2019-03-21 05:29:18 -0500 )edit

@LBerger: what list please?

Son Le gravatar imageSon Le ( 2019-03-21 05:47:55 -0500 )edit

@Son Le -- advice: forget the idea.

those installers work nicely with pure python code, but opencv is mainly a c++ library, all the code is inside cv2.pyd/so, and you won't ever get something really portable.

also, all of this is quite off-topic, imho.

berak gravatar imageberak ( 2019-03-21 12:17:54 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
-1

answered 2019-03-21 11:51:55 -0500

supra56 gravatar image

updated 2019-03-21 11:54:01 -0500

I soled your problem. I removed declared variable out.

import cv2

cap = cv2.VideoCapture(0)
while(True):
    ret, frame = cap.read()
    rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2BGRA)
    cv2.imshow('frame', rgb)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        cv2.imwrite('capture.jpg', frame)
        break
cap.release()
cv2.destroyAllWindows()
edit flag offensive delete link more

Comments

@Son Le . You need booatloader.

supra56 gravatar imagesupra56 ( 2019-03-21 21:10:46 -0500 )edit

@supra56 I copied your code and convert to .exe file but it still has problem after I run that exe file. Have you tried it yet? if yes, can you send me the exe file please?

Son Le gravatar imageSon Le ( 2019-03-21 21:16:03 -0500 )edit
1

i think the problem is not in code. PyInstaller do not include the file in opencv to excutable file.

hung.nguyen gravatar imagehung.nguyen ( 2019-03-21 21:18:38 -0500 )edit

Your is 32bit or 64bit?. I can't send it, because I am using raspberry pi linux. What python version?

supra56 gravatar imagesupra56 ( 2019-03-21 21:26:49 -0500 )edit

@Son Le. How do you run script command?

supra56 gravatar imagesupra56 ( 2019-03-21 21:29:19 -0500 )edit

@supra56 this is command "pyinstaller --onfile --noconsole myapp.py", I use python 3.6, pyinstaller 3.4, win10 64 bit. Thanks

Son Le gravatar imageSon Le ( 2019-03-21 22:27:19 -0500 )edit

by the way, do I have to have any .dll file to run it? I search around and some people say that I need dll files but I have no idea about it...

Son Le gravatar imageSon Le ( 2019-03-21 22:29:55 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-03-21 00:04:48 -0500

Seen: 85 times

Last updated: Mar 21