psc = cv2.createShapeContextDistanceExtractor().computeDistance(contour, contour) cv2.error: OpenCV(4.7.0) D:\a\opencv-python\opencv-python\opencv_contrib\modules\shape\src\sc_dis.cpp:204: error: (-215:Assertion failed) (set1.channels()==2) && (set1.cols>0) in function 'cv::ShapeContextDistanceExtractorImpl::computeDistance'
时间: 2023-07-23 22:09:04 浏览: 172
这个错误可能是由于传递给 `computeDistance` 方法的轮廓 `contour` 格式不正确引起的。确保 `contour` 变量的形状是 `(N, 1, 2)`,其中 `N` 是轮廓点的数量。如果您已经使用 `cv2.findContours` 查找了轮廓,那么 `contour` 变量应该已经符合要求,否则您可以使用以下代码将其转换为正确的格式:
```
contours, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
contour = contours[0]
contour = contour.reshape(-1, 1, 2)
```
在上面的代码中,我们假设 `thresh` 是二值化后的图像,`cv2.RETR_EXTERNAL` 表示只查找最外层的轮廓,`cv2.CHAIN_APPROX_SIMPLE` 表示使用简单的逼近方法来压缩轮廓。
如果您仍然遇到问题,请检查您的 OpenCV 版本是否正确安装,并确保您的轮廓变量格式正确。
相关问题
DELIMITER $$ CREATE /*[DEFINER = { user | CURRENT_USER }]*/ PROCEDURE `qy_task`.`peopletask`(IN job VARCHAR(200),IN seriesid VARCHAR(200),IN classid VARCHAR(200),IN prodid VARCHAR(200),IN cycleid VARCHAR(200) ) /*LANGUAGE SQL | [NOT] DETERMINISTIC | { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA } | SQL SECURITY { DEFINER | INVOKER } | COMMENT 'string'*/ BEGIN #把表围绕id创建一边然后再关联输出数据 CREATE TEMPORARY TABLE IF NOT EXISTS taskpeople SELECT gst.job_number, '' AS AREA, SUM(gst.amount) AS amount, SUM(gst.weight) AS weight, SUM(gst.area) AS AREA, SUM(qsc.weight) AS taskweight, SUM(qsc.weight)/SUM(gst.weight) AS percent FROM qy_goal_salesman_task gst INNER JOIN qy_goal_area_task gat ON gat.id =gst.area_task_id INNER JOIN qy_goal_company_task gct ON gct.id=gst.company_task_id INNER JOIN qy_goal_sale_cycle_config scc ON scc.id=gct.cycle_id INNER JOIN qy_goal_prod_config gpc ON gpc.id=gst.prod_id AND gpc.cycle_id=scc.id INNER JOIN qy_goal_prod_series_config psc ON psc.id=gpc.prod_series_id AND psc.cycle_id=scc.id INNER JOIN qy_goal_prod_classify_config pcc ON pcc.id = psc.prod_type_id AND pcc.cycle_id=scc.id INNER JOIN qy_goal_client_task_detail ctd ON gst.salesman_id=ctd.id INNER JOIN qingyuan.sys_circle sc ON sc.id=ctd.client_id INNER JOIN crm_c_duty_saler duty ON duty.c_id=sc.id INNER JOIN qyng_sys_user qsu ON qsu.id= duty.User_Id LEFT JOIN qy_sys_countydetail qsc ON qsc.proname=Pro_Name WHERE scc.id=cycleid AND qsc.CreateTime>=(SELECT start_date FROM qy_goal_sale_cycle_config WHERE id=cycleid) AND qsc.CreateTime<=(SELECT end_date FROM qy_goal_sale_cycle_config WHERE id=cycleid) AND qsc.GetTime=(SELECT MAX(GetTime) FROM qy_sys_countydetail) AND gpc.id=prodid AND pcc.id=classid AND psc.id=seriesid AND gst.job_number=job GROUP BY gst.job_number; #将临时表进行数据转换 UPDATE taskpeople SET job_number= ff.User_Name FROM taskpeople e INNER JOIN qyqx.qy_staff ff ON e.job_number=ff.uid; #查出真正的表 SELECT * FROM taskpeople; #删除临时表 DROP TEMPORARY TABLE taskpeople; END$$ DELIMITER ;这段mysql存储过程哪里出现了语法错误
这段 MySQL 存储过程中出现了语法错误,具体来说是在以下这行代码:
```
GROUP BY gst.job_number;
```
末尾多了一个分号,应该改为:
```
GROUP BY gst.job_number;
```
u16 pwm1_arr=1800,pwm1_psc=2,//pwm1初始arr psc 72000/2/1800=20khz pwm pwm2_arr=1800,pwm2_psc=2;//pwm2初始arr psc u16 pwm1_pluse,pwm2_pluse ;
这段代码是关于STM32的PWM模块的初始化代码。其中,pwm1_arr和pwm2_arr分别表示PWM计数器的自动重载值,pwm1_psc和pwm2_psc则表示PWM计数器的预分频值。通过这些参数可以计算出PWM输出的频率,公式为:PWM输出频率=定时器时钟频率/(pwm_arr+1)/(pwm_psc+1)。
另外,pwm1_pluse和pwm2_pluse则是用来控制PWM输出占空比的变量。在实际应用中,可以通过修改这些变量的值来调整PWM输出的占空比,从而控制电机、灯光等设备的运行状态。
阅读全文