OpenCV

Invalid number of channels in input image error using OpenCV

∥☆過路亽.° 提交于 2021-02-17 06:58:06
问题 cv2.error: OpenCV(4.2.0) c:\projects\opencv python\opencv\modules\imgproc\src\color.simd_helpers.hpp:92: error: (-2:Unspecified error) in function '__cdecl cv::impl::`anonymous- namespace'::CvtHelper<struct cv::impl::`anonymous namespace'::Set<3,4,-1>,struct cv::impl::A0xe227985e::Set<1,-1,-1>,struct cv::impl::A0xe227985e::Set<0,2,5>,2>::CvtHelper(const class cv::_InputArray &,const class cv::_OutputArray &,int) > Invalid number of channels in input image: > 'VScn::contains(scn)' > where >

Invalid number of channels in input image error using OpenCV

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-17 06:58:04
问题 cv2.error: OpenCV(4.2.0) c:\projects\opencv python\opencv\modules\imgproc\src\color.simd_helpers.hpp:92: error: (-2:Unspecified error) in function '__cdecl cv::impl::`anonymous- namespace'::CvtHelper<struct cv::impl::`anonymous namespace'::Set<3,4,-1>,struct cv::impl::A0xe227985e::Set<1,-1,-1>,struct cv::impl::A0xe227985e::Set<0,2,5>,2>::CvtHelper(const class cv::_InputArray &,const class cv::_OutputArray &,int) > Invalid number of channels in input image: > 'VScn::contains(scn)' > where >

HandGesture Detection

*爱你&永不变心* 提交于 2021-02-17 05:17:12
问题 When I run this: contours,_,hierarchy = cv2.findContours(thresh.copy(),cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE) I get this error: ValueError: not enough values to unpack (expected 3, got 2) I have also tried: _, contours,hierarchy = cv2.findContours(thresh.copy(),cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE) and: contours,hierarchy,_ = cv2.findContours(thresh.copy(),cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE) and got this error: Traceback (most recent call last): File "C:/Users/HASHMATI/AppData/Local/Programs

How to save a video in Python OpenCV

烈酒焚心 提交于 2021-02-17 03:35:36
问题 I have opened a Video using CV2, made some changes using cv2.rectangle . Now, when I do cv2.imshow('frame',frame) , it plays the video. Instead of this, I want to save the video somewhere, in the original size and frame rate. 回答1: You can save video frame by frame. Based on example on docs: Open Cv video capture import numpy as np import cv2 cap = cv2.VideoCapture(0) # Define the codec and create VideoWriter object fourcc = cv2.VideoWriter_fourcc(*'XVID') out = cv2.VideoWriter('output.avi'

How to save a video in Python OpenCV

China☆狼群 提交于 2021-02-17 03:35:11
问题 I have opened a Video using CV2, made some changes using cv2.rectangle . Now, when I do cv2.imshow('frame',frame) , it plays the video. Instead of this, I want to save the video somewhere, in the original size and frame rate. 回答1: You can save video frame by frame. Based on example on docs: Open Cv video capture import numpy as np import cv2 cap = cv2.VideoCapture(0) # Define the codec and create VideoWriter object fourcc = cv2.VideoWriter_fourcc(*'XVID') out = cv2.VideoWriter('output.avi'

Linking OpenCV to Qt Creator

不羁的心 提交于 2021-02-17 03:27:27
问题 I'm trying to use opencv 4 in QT creator, I'm working on Mac but I can't be able to link the library, I always have a error like on picture 2. please help me, I'm really hopeless. 回答1: First of all be sure you installed OpenCV correctly and working fine. You can check OpenCV exist or not by: pkg-config --modversion opencv It depends how you installed OpenCV but linking OpenCV libraries and flags to Qt is simply like adding these two line to your .pro file: INCLUDEPATH += /usr/local/include

opencv compile with clang ok, with gcc not ok os x 10.9

夙愿已清 提交于 2021-02-17 02:06:44
问题 I am on OS X 10.9, with opencv-2.4.8.2 installed. I am trying to compile a simple code: #include <stdio.h> #include <opencv2/opencv.hpp> using namespace cv; int main(int argc, char** argv ) { if ( argc != 2 ) { printf("usage: DisplayImage.out <Image_Path>\n"); return -1; } Mat image; image = imread( argv[1], 1 ); if ( !image.data ) { printf("No image data \n"); return -1; } namedWindow("Display Image", WINDOW_AUTOSIZE ); imshow("Display Image", image); waitKey(0); return 0; } and can do that

opencv compile with clang ok, with gcc not ok os x 10.9

一曲冷凌霜 提交于 2021-02-17 02:06:42
问题 I am on OS X 10.9, with opencv-2.4.8.2 installed. I am trying to compile a simple code: #include <stdio.h> #include <opencv2/opencv.hpp> using namespace cv; int main(int argc, char** argv ) { if ( argc != 2 ) { printf("usage: DisplayImage.out <Image_Path>\n"); return -1; } Mat image; image = imread( argv[1], 1 ); if ( !image.data ) { printf("No image data \n"); return -1; } namedWindow("Display Image", WINDOW_AUTOSIZE ); imshow("Display Image", image); waitKey(0); return 0; } and can do that

Ubuntu16.04安装编译caffe以及一些问题记录

五迷三道 提交于 2021-02-17 02:04:32
前期准备: 最好是python虚拟环境 【anaconda的创建虚拟环境】 创建 conda create -n caffeEnv(虚拟环境名字) python=3.6 激活环境 source activate caffeEnv 关闭 deactivate 【python virtualenv创建虚拟环境】 创建 pip install virtualenv sudo apt-get virtualenv virtualenv caffeEnv(虚拟环境名字) -p /usr/bin/python3(版本) 激活 cd caffeEnv && source ./bin/activate 关闭 deactivate 环境条件 深度学习加速模块和opencv cuda8.0+cudnn5.1+opencv3.4.0 cuda9.1+cudnn7.0+opencv3.4.0 ​ (我试过8.0+5.1和9.1+7.0都可以) ​ 安装教程另外两片博客记录了 安装cuda和cudnn教程 安装opencv教程 ​ caffe依赖库 sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler sudo apt-get

How would I find the mode (stats) of pixel values of an image?

…衆ロ難τιáo~ 提交于 2021-02-16 21:05:58
问题 I'm using opencv and I'm able to get a pixel of an image-- a 3-dimensional tuple, via the code below. However, I'm not quite sure how to calculate the mode of the pixels values in the image. import cv2 import numpy as np import matplotlib.pyplot as plt import numpy as np import cv2 img =cv2.imread('C:\\Users\Moondra\ABEO.png') #px = img[100,100] #gets pixel value #print (px) I tried, from scipy import stats stats.mode(img)[0] But this returns an array shape of stats.mode(img)[0].shape (1, 800