在sklearn的Polynomial Features中需要帮助.它对一个功能很有效,但每当我添加多个功能时,除了提升到度数的值之外,它还会在数组中输出一些值.例如:对于这个数组,
X=np.array([[230.1,37.8,69.2]])
Run Code Online (Sandbox Code Playgroud)
当我尝试
X_poly=poly.fit_transform(X)
Run Code Online (Sandbox Code Playgroud)
它输出
[[ 1.00000000e+00 2.30100000e+02 3.78000000e+01 6.92000000e+01
5.29460100e+04 8.69778000e+03 1.59229200e+04 1.42884000e+03
2.61576000e+03 4.78864000e+03]]
Run Code Online (Sandbox Code Playgroud)
这是8.69778000e+03,1.59229200e+04,2.61576000e+03什么?
我收到此错误:
OpenCV Error: Assertion failed (hpoints > 0) in cv::convexityDefects, file C:\projects\opencv-python\opencv\modules\imgproc\src\convhull.cpp, line 284
Traceback (most recent call last):
File "E:/PycharmProjects/ComputerVisionAgain/Image Segmentation/hand_blk/main.py", line 12, in <module>
hull_defects=cv2.convexityDefects(sorted_cnts[0],hull)
cv2.error: C:\projects\opencv-python\opencv\modules\imgproc\src\convhull.cpp:284: error: (-215) hpoints > 0 in function cv::convexityDefects
Run Code Online (Sandbox Code Playgroud)
当我尝试获取图像最大轮廓的凸度缺陷时。这是我正在使用的代码:
import cv2
import numpy as np
img=cv2.imread('blk_hand.jpg')
gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
ret,thresh=cv2.threshold(gray,100,255,cv2.THRESH_BINARY)
_,contours,h=cv2.findContours(thresh,cv2.RETR_LIST,cv2.CHAIN_APPROX_NONE)
sorted_cnts=sorted(contours,key=cv2.contourArea,reverse=True)
hull=cv2.convexHull(sorted_cnts[0])
hull_defects=cv2.convexityDefects(sorted_cnts[0],hull)
cv2.drawContours(img,[hull],-1,(0,0,255),3)
cv2.drawContours(img,sorted_cnts[0],-1,(0,255,0),3)
cv2.imshow('img',img)
cv2.imshow('thresh',thresh)
cv2.waitKey(0)
Run Code Online (Sandbox Code Playgroud)