Special Collection AnalysisThe dataset is Letter-recognition.data, with a total of 20,000 data, separated by commas, the data instance is shown below, the first column is the letter mark, and the remainder is a different feature. t,2,8,3,5,1,8,13,0,6,6,10,8,0,8,0,8Learning methods1. Read in the data and remove the separator number2, the first column of data as a marker, the rest of the training data3. Initialize the classifier and train with training data4, the use of test data to verify the acc
In this paper, "PYTHON+OPENCV practice" A, color-based object tracking (I.)
The functional enhancements were made as follows:
(1) The addition of PTS emptying, that is, when the target is not detected, empty PTS, showing no longer traces of the image;
(2) The direction of motion and the current coordinate can be judged by the addition of the movement directions.
From collections import deque import NumPy a
彩色, another color BGR plt.subplot (1 , 2 , 2 ), plt.imshow (erosion, ) (v) Morphological gradientsThe combination of expansion and corrosion makes the result appear to be the same as extracting the contour of the object.import cv2import numpy as npimport Matplotlib.pyplot as pltimg = cv2.imread ( ' man.jpg ' , 0 ) #直接读为灰度图像 kernel = np.ones ((5 , 5 ), np.uint8) closing= Cv2.morphologyex (Img,cv2. Morph_gradient,kernel) Plt.subplot (1 , 2 , 1 ), Plt.imshow (Img,) #默认彩色, another color BG
bilateral filter code is as follows:#encoding: Utf-8Import NumPy as Npimport cv2image = Cv2. Imread("H:\\img\\lena.jpg") Cv2. Imshow("Original", image) Cv2. Waitkey(0)#双边滤波Blurred = NP. Hstack([Cv2. Bilateralfilter(Image,5, +, +), Cv2. Bilateralfilter(Image,7, to, to), Cv2. Bilateralfilter(Image,9, A, A)]) Cv2. Imshow("Bilateral", blurred) Cv2. Waitkey(0)The results are as follows: Original image:Image after drawing (refer to the explanation in the above function prototype for the relevant para
Python uses opencv to read images,
After the environment is installed, the first Hello word example is started: how to read images and save images
Import cv2import numpy as npimport matplotlib. pyplot as plt # Read image Code img = cv2.imread('test.jpg ', cv2.IMREAD _ GRAYSCALE) # IMREAD_COLOR = 1 # IMREAD_UNCHANGED =-1 # Show image cv2.imshow ('image', img) cv2.waitKey (0) cv2.destroyAllWindows () # Use
1. Capture camera and real-time displayImport Cv2import numpy as Npimport pickleimport matplotlib.pyplot as Pltcap = Cv2. Videocapture (0) while True: ret,frame = Cap.read () # We operations on the frame come here Gray = Cv2.cvtcolor ( Frame, Cv2. Color_bgr2gray) # Display The resulting frame cv2.imshow (' frame ', gray) if Cv2.waitkey (1) 0xFF = = Ord ( ' Q '): Break # When everything done, release the Capturecap.release () cv2.destroyallwindows () 2. Capture the pictu
Import Cv2import Numpyimport os# make an array of 120,000 random Bytes.randombytearray = ByteArray (Os.urandom (120000)) flat Numpyarray = Numpy.array (randombytearray) # Convert The array to make a 400x300 grayscale image.grayimage = Flatnumpyarray. Reshape (+) cv2.imwrite (' Randomgray.png ', grayimage) # Convert The array to make a 400x100 color Image.bgrimage = flat Numpyarray.reshape (+, 3) cv2.imwrite (' Randomcolor.png ', bgrimage)"Python uses
. Param2, there is also a default value of 100. It is the corresponding parameter of the method set for the detection. The current only method of the Hough gradient method, which represents the accumulator threshold at the center of the detection phase. The smaller it is, the more it can detect a circle that doesn't exist, and the bigger it is, the more rounded it is to be able to pass through the circle. Minradius, the default value of 0, represents the minimum value of the circle radius. Maxra
Get pixel values and modify# gets the pixel value of the specified coordinate img[i, j]# modifies the pixel value of the specified coordinates img[i, j] = [R, G, b]NumPy is an optimized package for fast matrix operations.Therefore, it is not recommended to change pixels by pixel value, which is very slow. Do not use loops when you can use matrix operationsImg.item (2) Img.itemset ((10, 10, 2), 100)Get the properties of an image# get the shape of an image Img.shape # returns the number of pixels
You can look at this blog posthttp://blog.csdn.net/taily_duan/article/details/52165458The test picture can be found herehttps://www.raspberrypi.org/blog/real-time-depth-perception-with-the-compute-module/The following two lines of code appear to be invalid because of a version replacement.Deparsity = Cv2. STEREOBM (Cv2. Stereo_bm_basic_preset,ndisparities=16, sadwindowsize=15)deparsity = CV2.CREATESTEREOBM (numdisparities=16, blocksize=25)#测试代码如下:#-*-coding:utf-8-*-ImportNumPy as NPImportCv2 fro
), checks if initialization succeeded, returns successfully True return value: Boolean "" "while (Cap.isopened ()): #循环读取每一帧" "" Function Name: Cap.read () function: Returns two values first returns a Boolean value if the video read is correct, true if Error, or false, can also be used to determine whether to the end of the video and return a value for each frame of the image, the value is a three-dimensional matrix universal Receive method is: Ret,frame = Cap.read (); So ret store Bo
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.