TensorFlow sequential model is not recognising the full shape of the data

import tensorflow as tf from traffic import IMG_WIDTH, IMG_HEIGHT import cv2 import os import numpy as np model = tf.keras.models.load_model("neural-network") image = cv2.imread("gtsrb\\1\\00000_00000.ppm") image = cv2.resize(image, (IMG_WIDTH, IMG_HEIGHT)) print(image.shape) model.predict(image) The image.shape doesn’t agree with the shape that the model reads in the model.predict() line I run this code, and the image.shape is (30,30,3) but… Read More TensorFlow sequential model is not recognising the full shape of the data

AttributeError: 'cv2.VideoCapture' object has no attribute 'isOpend'

I have a problem using OpenCV with VS Code I checked version of OpenCV and Python, but I don’t know what’s wrong. opencv version is 4.7.0 vscode interpreter is python 3.9.13(‘base’) /opt/anaconda3/bin/python here is condalist opencv-contrib-python 4.7.0.72 pypi_0 pypi opencv-python 4.7.0.72 pypi_0 pypi this is my code import cv2 import sys cap = cv2.VideoCapture(0) if… Read More AttributeError: 'cv2.VideoCapture' object has no attribute 'isOpend'

Plot image at center of label in PyQT

QGridLayout is used to place QLabel. Then cv2 images are displayed as follows. frame = self.dequeList[cam.camID].popleft() img = QtGui.QImage(frame, frame.shape[1], frame.shape[0], QtGui.QImage.Format_RGB888).rgbSwapped() pix = QtGui.QPixmap.fromImage(img) self.videoList[f"video_{cam.camID}"].setPixmap(pix) Now display start from 0,0 coordinates as below. I like to display image at the center of label. How can I do that? >Solution : To plot the image… Read More Plot image at center of label in PyQT

AttributeError: 'builtin_function_or_method' object has no attribute 'apply'

cv2 Problem.. I was watching not that old of a tutorial about object tracking and stumbled in this error AttributeError: ‘builtin_function_or_method’ object has no attribute ‘apply’ This is the code around the issue. object_detector = cv2.createBackgroundSubtractorMOG2 while True: ret, frame = cap.read() mask = object_detector.apply(frame) cv2.imshow("Frame", frame) cv2.imshow("Mask", mask) In The tutorial the guy did… Read More AttributeError: 'builtin_function_or_method' object has no attribute 'apply'

Recreate colormap based on colorscale in matplotlib

I have an image of a color scale I filter out the actual color scale by using import cv2 import numpy as np colorbar = cv2.imread(‘colorbar-scheme-elevation.png’, cv2.IMREAD_UNCHANGED) colorbar = cv2.cvtColor(colorbar, cv2.COLOR_BGRA2BGR) hsv = cv2.cvtColor(colorbar, cv2.COLOR_RGB2HSV) lower_gray = np.array([0, 0, 0]) upper_gray = np.array([255, 10, 255]) mask = cv2.inRange(hsv, lower_gray, upper_gray) mask = cv2.bitwise_not(mask) res =… Read More Recreate colormap based on colorscale in matplotlib

OpenCV Python, watermark can't be seen on white backgrounds

I am trying to paste my watermark to white-backgrounded image: watermark = cv2.imread(watermark_path) watermark_ratio = round(image.shape[1]/8) # calculating the ratio resized_watermark = cv2.resize(watermark, (watermark_ratio, round(watermark_ratio/2)), interpolation = cv2.INTER_AREA) # resizing watermark size h_logo, w_logo, _ = resized_watermark.shape h_img, w_img, _ = image.shape top_y = h_img – h_logo left_x = w_img – w_logo bottom_y = h_img… Read More OpenCV Python, watermark can't be seen on white backgrounds