2

I am getting Corrupt JPEG data: 1 extraneous bytes before marker 0xd3 error while using functions of opencv as mentioned in the code section. I am running this code using python3 in Raspberry Pi 3.

I found that manually updating the kernel resolve this issue in some cases and would like to know how to update it.

     video = cv2.VideoCapture(0)
     ret, frame=video.read()
     if ret == True:  
       cv2.imwrite(str(time.time()) + '.jpg',frame)  

Kindly guide about ways to remove this error.

Bilal
  • 29
  • 1
  • 6
  • Do you mean `cv2.imwrite()` creates a JPEG that some other application cannot read? If so, please share the JPEG, the exact error message and the name & version of whatever application it is. If you mean something else, please clarify. Thank you. – Mark Setchell Jul 02 '19 at 09:36
  • That is not what I asked you. Could you answer what I asked you please? – Mark Setchell Jul 02 '19 at 16:16
  • According to code, frames from webcam is stored as JPEG file with its name as current Timestamp.Now the frames are saved with their names as Time Stamp but there is set of number added in it's name like this 1562083791.9949021.jpg. When I will access this image with Time stamp it wont work because of the extra digits added in it's name. When I run it, it saves the images but with this problem and there appears error Corrupt JPEG data: 1 extraneous bytes before marker 0xd3. – Bilal Jul 02 '19 at 16:18
  • Which part is the extra number stored in the name? – Mark Setchell Jul 02 '19 at 16:21
  • I hope I answered what you ask. Kindly inform if there is any other point need to be mentioned. I am using python3 with opencv. Its just a python code to save the frames of video from a webcam using opencv. I think its due to some error in opencv installation. Because some time ago when I run this python code the frames were saved with the timestamps only like 1562083791.90.jpg now there are some false random numbers added to the file name along with the time stamp. – Bilal Jul 02 '19 at 16:24
  • After decimal point in the time stamp like 9949021. – Bilal Jul 02 '19 at 16:26
  • I have been trying to install opencv in Raspberry Pi 3 for 3 days but I cant figure out where is that error. Please guide how to come out of this error. – Bilal Jul 02 '19 at 16:28
  • If you run `print(time.time())` you will see that the decimal fraction of seconds is normal. I don't see why you think this name causes a problem. Also, you said you get an error saying there are extraneous bytes before the marker and I asked you which application tells you that, and also I asked you to share a corrupt image. – Mark Setchell Jul 02 '19 at 16:28
  • The image is not corrupted its alright as before. I am runing the python file from the linux terminal by this command python3 x.py On the linux terminal this error appears everytime the frame is saved. – Bilal Jul 02 '19 at 16:33
  • Also the same error appears when I run this through Thonny Python IDE. – Bilal Jul 02 '19 at 16:44

0 Answers0