In: Computer Science
(a) An expert system developer lost a court case about a newly deployed system. The general issue was based on the fact that the new system could not be differentiated from the old systems even though the new system functioned normally. In ten points, explain the specific issues about the system that the developer likely failed to present at the compiling stage.
(b) The following code lines represent a simple expert system
about a cancer image detection under computer vision. You are
required to identify and explain the effect of the different
command lines;
4
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
while(1):
_, frame = cap.read()
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
lower_red = np.array([0,0,0])
upper_red = np.array([255,255,180])
mask = cv2.inRange(hsv, lower_red, upper_red)
res = cv2.bitwise_and(frame,frame, mask= mask)
cv2.imshow('frame',frame)
cv2.imshow('mask',mask)
cv2.imshow('res',res)
k = cv2.waitKey(5) & 0xFF
if k == 27:
break
cv2.destroyAllWindows()
cap.release()
import cv2
import numpy as np
cap = cv2.VideoCapture(0) # your webcam as video source 0 param for webcam
while(1):
_, frame = cap.read() # reads a single frame in frame variable
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) # convert the BGR(blue,Green,Red) to hsv(hue,saturation , value) chennal
lower_red = np.array([0,0,0]) # define a lower limit
upper_red = np.array([255,255,100]) # define a upper limit
mask = cv2.inRange(hsv, lower_red, upper_red) # mask[i][j][k] == 1 if the value of color red in 0 <=frame[i][j][k] <= 180 else mask[i][j][k] = 0; just fiter red
# take the bitwise_and of the frame with itself. and output will be res[i][j][k] = frame[i][j][k] & frame[i][j][k] if mask[i][j][k] != 0
# that means the pixels where red color is between 0 and 180 are captured and rest are made 0 means black.
res = cv2.bitwise_and(frame,frame, mask= mask)
cv2.imshow('frame',frame) #showing the "frame" frame
cv2.imshow('mask',mask) # showing the "mask" frame
cv2.imshow('res',res) # showing the "res" frame
k = cv2.waitKey(5) & 0xFF # caputre any keypress
if k == 27: # if keypress is Esc then break;
break
cv2.destroyAllWindows() # destroy all windows for frames
cap.release() # release the resources