opencv3.0

how to read images from my home directory and resize it

馋奶兔 提交于 2020-02-03 10:14:49
问题 I am trying to read the images and resize the image in my home directory file but didn't work please help how to read images and resize it. import cv2 from PIL import Image img = cv2.resize(cv2.read('C://Users//NanduCn//jupter1//train-scene classification//train"', (28, 28))) --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-103-dab0f11a9e2d> in <module>() 1 import cv2 2 from PIL import Image ----> 3 img

how to read images from my home directory and resize it

雨燕双飞 提交于 2020-02-03 10:12:59
问题 I am trying to read the images and resize the image in my home directory file but didn't work please help how to read images and resize it. import cv2 from PIL import Image img = cv2.resize(cv2.read('C://Users//NanduCn//jupter1//train-scene classification//train"', (28, 28))) --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-103-dab0f11a9e2d> in <module>() 1 import cv2 2 from PIL import Image ----> 3 img

opencv canny: Do minVal and maxVal matter if you're working with a black and white image?

流过昼夜 提交于 2020-01-25 02:52:43
问题 Preface: This is a continuation of this question. Consider the following code, taken from here: import cv2 import numpy as np from matplotlib import pyplot as plt img = cv2.imread('messi5.jpg',0) edges = cv2.Canny(img,100,200) # Would 100 and 200 matter if your original image was black and white? plt.subplot(121),plt.imshow(img,cmap = 'gray') plt.title('Original Image'), plt.xticks([]), plt.yticks([]) plt.subplot(122),plt.imshow(edges,cmap = 'gray') plt.title('Edge Image'), plt.xticks([]),

Creating BackgroundSubtractorMOG2 in Android by OpenCV 3.0 RC1

99封情书 提交于 2020-01-24 18:49:26
问题 I'm trying to do background subtraction with MOG2 in OpenCV 3.0 on my android phone. However, it seems that there are no suitable constructor to create a new BackgroundSubtractorMOG2 in version 3.0. My code lies down here. @Override public void onCameraViewStarted(int width, int height) { mFrame = new Mat(height, width, CvType.CV_8UC4); mFgMaskMOG = new Mat(height, width, CvType.CV_8UC1); pMOG2 = new BackgroundSubtractorMOG2(); } With these codes Android studio reminds me that the constructor

Image Capture with OpenCV - Select Timeout Error

核能气质少年 提交于 2020-01-24 09:16:31
问题 I would like to save a captured image from my webcam attached BeagleBone Black, however when I run the following code, I get the error: select timeout. #include <iostream> #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include "opencv2/opencv.hpp" #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/videoio.hpp" using namespace std; using namespace cv; int main(){ cout<< "Hello, OpenCV version: "<< CV_VERSION << endl; Mat frame; VideoCapture cap(0); cap.set(CV

How to remove whitespace from an image in OpenCV?

扶醉桌前 提交于 2020-01-21 01:31:36
问题 I have the following image which has text and a lot of white space underneath the text. I would like to crop the white space such that it looks like the second image. Cropped Image Here is what I've done >>> img = cv2.imread("pg13_gau.jpg.png") >>> gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) >>> edged = cv2.Canny(gray, 30,300) >>> (img,cnts, _) = cv2.findContours(edged.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) >>> cnts = sorted(cnts, key = cv2.contourArea, reverse = True)[:10] 回答1: As

opencv structured forest edge detection and findcontours

≯℡__Kan透↙ 提交于 2020-01-17 06:38:57
问题 I am trying to use opencv via visual c++ to extract contours of an image. I was able to do that using the opencv tutorial for findcontours. findcontours works in two steps Detect edges using canny edge detector. Feed the output of canny to findcontours. I want to try out the same with 'Structured Forest Edge Detection' (Zitnick et al). I am able to extract the edges and display them, but when I try to feed the output to findcontours. I am getting a 'cv::Exception at memory location 0x0020EE9C

How can I make the gradient appearance of one image equal to the other?

泄露秘密 提交于 2020-01-16 19:34:27
问题 I have an image A with shadow appearance in it and I have an image B which is of solid color. I want to copy shadows of image A to Image B from openCV in python. If I am not wrong it has something to do with gradient of the image? Image A Image B 回答1: You can do that easily with ImageMagick or Python Wand or with a bit more effort in Python/OpenCV. Note that Python Wand uses ImageMagick. ImageMagick is already available on most Linux distributions and is available for Windows and Mac OSX. The

Type Error: Only length-1 arrays can be converted to Python Scalars

空扰寡人 提交于 2020-01-14 13:56:30
问题 I am a beginner to openCV and am trying to analyse an existing code for a sudoku solver. There is this section of code which throws an error. samples = np.float32(np.loadtxt('feature_vector_pixels.data')) responses = np.float32(np.loadtxt('samples_pixels.data')) model = cv2.ml.KNearest_create() model.train(samples, responses) The error is as follows Type Error: Only length-1 arrays can be converted to Python Scalars . The complete traceback is as below: C:\Study stuff\FinalProject>c:\Python27

Opencv Undefined symbols for architecture cv:imwrite Mac osX high Sierra

雨燕双飞 提交于 2020-01-14 03:00:08
问题 I downloaded GCC and opencv(3.4.1_2) in my Mac OS X high Sierra(10.13.3) through homebrew. $ g++ --version g++-7 (Homebrew GCC 7.3.0_1) 7.3.0 In my "opencvtest.cpp", cv::imwrite was seen as undefined symbols for architecture but other functions such as cv::imread, cv::namedWindow worked perfectly. #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgcodecs.hpp" #include <iostream> using namespace cv; int main( int argc, char** argv ) { Mat img = imread( argv[1], -1 ); if( img.empty() )