Ask Your Question
-1

Non-ASCII character '\xa0' in file

asked 2017-04-11 07:04:51 -0600

Hi I am a starter in Python and Opencv. I have tried for this code blow for opening a avi file:

Code:

import cv
vidFile = cv.CaptureFromFile("C:\test1.avi")
nFrames = int(cv.GetCaptureProperty( vidFile, cv.CV_CAP_PROP_FRAME_COUNT ) )
fps = cv.GetCaptureProperty( vidFile, cv.CV_CAP_PROP_FPS )

waitPerFrameInMillisec = int( 1/fps * 1000/1 )

print 'Num. Frames = ', nFrames
print 'Frame Rate = ', fps, ' frames per sec'

for f in xrange( nFram`enter code here`es ):
frameImg = cv.QueryFrame( vidFile )
  cv.ShowImage( "My Video Window",  frameImg )
  cv.WaitKey( waitPerFrameInMillisec  )
cv.DestroyWindow( "My Video Window" )

While an error happens:

Non-ASCII character '\xa0' in file C:\cantwork.py on line 5, but no encoding declared;

see python.org/dev/peps/pep-0263/ for details

Could anybody help me for this please? Appreciate

edit retag flag offensive close merge delete

Comments

please use cv2, not the deprecated cv api (which also does no more exist in recent opencv)

please start all over using this tutorial and come back, if the error persists

berak gravatar imageberak ( 2017-04-11 07:22:09 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2017-04-11 08:31:08 -0600

berak gravatar image

so, you somehow managed to get some non-ascii garbage into your python script.

to get rid of that (on windows) use type on the cmdline, and pipe it into a new file:

type my.py > my2.py

but anyway, you must not use that outdated api, so , throw it away and start from scratch using cv2 !

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-04-11 06:58:01 -0600

Seen: 1,421 times

Last updated: Apr 11 '17