OpenCV

opencv didn't output images correctly

微笑、不失礼 提交于 2021-02-11 17:11:10
问题 I have debugging my code and here is what I found: img = cv2.resize(img, (224, 224)) cv2.imshow("img",img) cv2.waitKey(0) cv2.destroyAllWindows() img = (img / 127.5) - 1 cv2.imshow("img",(127.5*(img+1)).astype(int)) cv2.waitKey(0) cv2.destroyAllWindows() these operations don't output the same picture even tough they are same, does somebody konow why? 回答1: Try checking the dtype each time you display: print(img.dtype) 来源: https://stackoverflow.com/questions/63371878/opencv-didnt-output-images

How to split a snowman shaped contour into two circles

一笑奈何 提交于 2021-02-11 17:11:08
问题 Problem I am processing an iPhone screen recording of a game automatic replay called Chinese Chess (I press the play button once, it automatically goes through all the moves). The screen recording is in 30FPS, and conveniently, every second (30 frames), a new move is made. For example, the 120th frame looks like this: 30 frames (1 second) later, the 150th frame looks like this: I want to detect each move played by comparing the previous frame to the current frame. My code works if the piece

opencv didn't output images correctly

此生再无相见时 提交于 2021-02-11 17:10:45
问题 I have debugging my code and here is what I found: img = cv2.resize(img, (224, 224)) cv2.imshow("img",img) cv2.waitKey(0) cv2.destroyAllWindows() img = (img / 127.5) - 1 cv2.imshow("img",(127.5*(img+1)).astype(int)) cv2.waitKey(0) cv2.destroyAllWindows() these operations don't output the same picture even tough they are same, does somebody konow why? 回答1: Try checking the dtype each time you display: print(img.dtype) 来源: https://stackoverflow.com/questions/63371878/opencv-didnt-output-images

Convert a kivy texture to opencv image

心已入冬 提交于 2021-02-11 17:09:51
问题 I am trying to convert my kivy texture to an image format so that i can process it using opencv (cv2). I tried reading the texture using read() and using cv2.imread() but neither worked. I also looked into converting the ubyte texture into a string but got nowhere. kivy camera texture -> format that i can process using cv2 something like MyVariable = someid.texture #do something to format of MyVariable so that it is an 'image' Newvar = MyVariable.read() #cv2 processing... EDIT: Ok so i got

How to split a snowman shaped contour into two circles

自古美人都是妖i 提交于 2021-02-11 17:04:14
问题 Problem I am processing an iPhone screen recording of a game automatic replay called Chinese Chess (I press the play button once, it automatically goes through all the moves). The screen recording is in 30FPS, and conveniently, every second (30 frames), a new move is made. For example, the 120th frame looks like this: 30 frames (1 second) later, the 150th frame looks like this: I want to detect each move played by comparing the previous frame to the current frame. My code works if the piece

OpenCV Facial Detection come ups with this error

匆匆过客 提交于 2021-02-11 16:56:57
问题 I keep getting this error: faces = face_cascade.detectMultiScale(gray, 1.3, 5) cv2.error: OpenCV(4.5.1) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-wvn_it83\opencv\modules\objdetect\src\cascadedetect.cpp:1689: error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale' when trying to run this code import cv2 import numpy as np face_cascade = cv2.CascadeClassifier('haarcascase_frontalface_default.xml') cap = cv2.VideoCapture(0) while 1: ret, img = cap

OpenCV Facial Detection come ups with this error

£可爱£侵袭症+ 提交于 2021-02-11 16:55:38
问题 I keep getting this error: faces = face_cascade.detectMultiScale(gray, 1.3, 5) cv2.error: OpenCV(4.5.1) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-wvn_it83\opencv\modules\objdetect\src\cascadedetect.cpp:1689: error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale' when trying to run this code import cv2 import numpy as np face_cascade = cv2.CascadeClassifier('haarcascase_frontalface_default.xml') cap = cv2.VideoCapture(0) while 1: ret, img = cap

Video from images with variable frame rate

别说谁变了你拦得住时间么 提交于 2021-02-11 16:30:02
问题 I'd like to create a video from still images, but instead of using a static FPS, I have a specific timestamp for each image (the images are not exactly evenly spaced in time). How could I go about doing this? My current code, with a static FPS, is as follows import cv2 import os image_folder = '/Users/alex/Dropbox/Apps/CCTV-AE/rasp2/saved/movies/' video_name = '/Users/alex/Dropbox/Apps/CCTV-AE/rasp2/saved/movies/video.avi' images = sorted([img for img in os.listdir(image_folder) if img

Video from images with variable frame rate

China☆狼群 提交于 2021-02-11 16:28:20
问题 I'd like to create a video from still images, but instead of using a static FPS, I have a specific timestamp for each image (the images are not exactly evenly spaced in time). How could I go about doing this? My current code, with a static FPS, is as follows import cv2 import os image_folder = '/Users/alex/Dropbox/Apps/CCTV-AE/rasp2/saved/movies/' video_name = '/Users/alex/Dropbox/Apps/CCTV-AE/rasp2/saved/movies/video.avi' images = sorted([img for img in os.listdir(image_folder) if img

Find number of close loops in Binary Edge Image

孤者浪人 提交于 2021-02-11 15:57:41
问题 I have a binary image with the number of close loops and free curves like shown in image.. My approach so far- (python code): Skeletonize the image to get edge of 1 pixel Use label/bwlabel to get individual curve/edge Applied DFS to get the edge which is not close Apply DFS to get close edge..but not working correctly.. Expected output - Number of close loops =6, the sum of the pixels along the loop or all (x,y) points along the edge of the close curve as highlighted in RED Expected Output-