ERPNext Didn't Support It?

The following code worked just fine on the system. However, on ERPNext it did not!
Why is that? Do I need to activate kind of integration?

    def validate(self):
        cap = cv2.VideoCapture(0)
        if not cap.isOpened():
            raise IOError('Cannot open camera. Check out the settings.')

        while True:
            ret, frame = cap.read()
            frame = cv2.resize(frame, None, fx=1, fy=1,
                               interpolation=cv2.INTER_AREA)
            cv2.imshow('Smile!', frame)

            c = cv2.waitKey(1)
            if c == 32:  # ASCII Code for space
                break

        cv2.imwrite('/home/omix/omar/c3.png', frame)
        cap.release()
        cv2.destroyAllWindows()

Seems opencv package. Is it?
You need to install the package on your environment and import it …

Yes I did, I did install the opencv using pip inside the virtual environment of frappe-bench and import it at the top of the code.

It worked after resetting the virtual machine, but now I get: Internal Server Error as a message