Code Rendering With Black Frame Scale
Code Rendering With Black Frame Scale
perspective = np.array([[self.camera_fx*self.camera_scale,
self.camera_skew*self.camera_scale, -
(self.camera_cx+self.camera_width*self.camera_frame_picture_ratio)*self.camera_scal
e, 0],
[0, self.camera_fy*self.camera_scale, -
(Cy+self.camera_height*self.camera_frame_picture_ratio)*self.camera_scale, 0],
[0, 0, (self.camera_near + self.camera_far),
(self.camera_near * self.camera_far)],
[0, 0, -1, 0]], dtype=np.float32)
P = np.matmul(ortho, perspective)
P = P.transpose()
self.projectionMatrix = P
def drawImage(self):
# glBindBuffer(GL_ARRAY_BUFFER, 0)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glDepthMask(GL_FALSE)
glDisable(GL_DEPTH_TEST)
glBindVertexArray(self.imageVAO)
glUseProgram(self.imageShaderProgram)
glUniform1f(self.quadScaleLoc, 1.0)
glUniform1f(self.quadAlphaLoc, self.imageAlpha)
glActiveTexture(GL_TEXTURE0)
glBindTexture(GL_TEXTURE_2D, self.textureId)
glDrawArrays(GL_TRIANGLES, 0, 6)
glBindVertexArray(0)
glBindTexture(GL_TEXTURE_2D, 0)
glUseProgram(0)
def drawModels(self):
glEnable(GL_DEPTH_TEST) # Depth buffer ON
glDepthMask(GL_TRUE)
glEnable(GL_CULL_FACE)
glBindBuffer(GL_ARRAY_BUFFER, 0)
glUniformMatrix4fv(self.mvMatrixLoc, 1, False,
self.modelviewMatrix.flatten())
glUniformMatrix3fv(self.normalMatrixLoc, 1, False,
self.normalMatrix.flatten())
glUniform3f(self.lightPosLoc, self.lightPosition[0],
self.lightPosition[1], self.lightPosition[2])
glUniform1f(self.usingLightFalloffLoc, 1.0)
glUniform1f(self.modelTexturemappingLoc, 0.0)
glUniform1f(self.modelTexScaleLoc, 1.0)
glUniform1f(self.modelCLoc, self.cForRendering)
glUniform4f(self.modelAmbientColourLoc, self.modelAmbientColour[0],
self.modelAmbientColour[1], self.modelAmbientColour[2], self.modelAmbientColour[3])
glActiveTexture(GL_TEXTURE0)
glBindTexture(GL_TEXTURE_2D, self.textureId)
glBindTexture(GL_TEXTURE_2D, 0)
glUseProgram(0)
image_orig = cv2.imread('../patient_data/20180905/image74.png')
self.background_image =
cv2.undistort(image_orig,self.camera_matrix,self.camera_dist_coeffs)
width, height = self.background_image.shape[1],
self.background_image.shape[0]
self.model_paths =
["../patient_data/20180905/models_registered_hepataug/tumour.obj",
"../patient_data/20180905/models_registered_hepataug/vein.obj",
"../patient_data/20180905/models_registered_hepataug/liver.obj"]
# Lightning parameters:
self.modelAmbientColour = [0.1, 0.1, 0.1, 1.0]
self.lightPosition = [0.0, 0.0, 0.0]
self.cForRendering = 0.03
self.imageShaderProgram = None
self.positionHandle = None
self.textureId = None
self.imageVAO = None
self.models = []
self.modelVAOs = []
self.modelVBOs = []
self.modelVertexData = []