Video capture not working properly

I have a application in python which I use VideoCapture to display a webcam frame on the screen. It used to work perfectly until suddenly something wents reallly wrong. I'm using the same code and the image seems to be very noisy.

I tried to work with different cameras and the problem is the same, so the problem is not with the camera. I tried the same code in a different computer. And the application seems to work normally. I wrote a very simple code, just to display the webcam frame in the screen and still I have the same issue.

It seems to be a conflict between opencv and my computer configuration. But I'm not able to figure what is going on.

I hope you can help me with this issue.

My simple code is:

# -*- coding: utf-8 -*-
"""
Created on Thu Oct 10 10:42:38 2019

@author: vitoro
"""

import cv2

cap = cv2.VideoCapture(1)
# Check if the webcam is opened correctly
if not cap.isOpened():
cap = cv2.VideoCapture(0)
if not cap.isOpened():
raise IOError("Cannot open webcam")

while True: