{"id":69616,"date":"2026-01-31T22:24:52","date_gmt":"2026-01-31T14:24:52","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/69616.html"},"modified":"2026-01-31T22:24:52","modified_gmt":"2026-01-31T14:24:52","slug":"opencv%e8%ae%a1%e7%ae%97%e6%9c%ba%e8%a7%86%e8%a7%89-%e5%85%89%e6%b5%81%e4%bc%b0%e8%ae%a1%e8%a7%86%e9%a2%91%e8%af%bb%e5%8f%96%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/69616.html","title":{"rendered":"opencv\u8ba1\u7b97\u673a\u89c6\u89c9--\u5149\u6d41\u4f30\u8ba1&amp;\u89c6\u9891\u8bfb\u53d6\u65b9\u6cd5"},"content":{"rendered":"<h3>\u4e00\u3001\u5149\u6d41\u4f30\u8ba1\u6982\u5ff5<\/h3>\n<p>\u5149\u6d41&#xff08;Optical Flow&#xff09;\u00a0\u662f\u8ba1\u7b97\u673a\u89c6\u89c9\u4e2d\u7528\u4e8e\u63cf\u8ff0\u56fe\u50cf\u4e2d\u50cf\u7d20\u70b9\u8fd0\u52a8\u6a21\u5f0f\u7684\u6280\u672f\u3002\u5b83\u57fa\u4e8e\u4ee5\u4e0b\u4e24\u4e2a\u57fa\u672c\u5047\u8bbe&#xff1a;<\/p>\n<li>\n<p>\u4eae\u5ea6\u6052\u5b9a\u5047\u8bbe&#xff1a;\u540c\u4e00\u7269\u4f53\u70b9\u5728\u8fde\u7eed\u5e27\u4e2d\u7684\u4eae\u5ea6\u4fdd\u6301\u4e0d\u53d8<\/p>\n<\/li>\n<li>\n<p>\u65f6\u7a7a\u8fde\u7eed\u6027\u5047\u8bbe&#xff1a;\u76f8\u90bb\u70b9\u5177\u6709\u76f8\u4f3c\u7684\u8fd0\u52a8<\/p>\n<\/li>\n<p>\u5149\u6d41\u4f30\u8ba1\u7684\u6838\u5fc3\u601d\u60f3\u662f&#xff1a;\u5728\u89c6\u9891\u5e8f\u5217\u4e2d&#xff0c;\u901a\u8fc7\u5206\u6790\u76f8\u90bb\u5e27\u4e4b\u95f4\u50cf\u7d20\u5f3a\u5ea6\u7684\u53d8\u5316\u6765\u4f30\u8ba1\u50cf\u7d20\u7684\u8fd0\u52a8\u901f\u5ea6\u548c\u65b9\u5411\u3002<\/p>\n<h3>\u4e8c\u3001\u51fd\u6570\u8be6\u89e3<\/h3>\n<h4>1.\u00a0cv2.goodFeaturesToTrack()\u00a0&#8211; Shi-Tomasi\u89d2\u70b9\u68c0\u6d4b<\/h4>\n<p>\u7528\u4e8e\u5728\u56fe\u50cf\u4e2d\u68c0\u6d4b\u89d2\u70b9&#xff08;\u7279\u5f81\u70b9&#xff09;&#xff0c;\u8fd9\u4e9b\u70b9\u9002\u5408\u8fdb\u884c\u5149\u6d41\u8ddf\u8e2a\u3002<\/p>\n<p>\u53c2\u6570\u8bf4\u660e&#xff1a;<\/p>\n<p>p0 &#061; cv2.goodFeaturesToTrack(image&#061;old_gray, mask&#061;None, **feature_params)<\/p>\n<ul>\n<li>\n<p>image&#xff1a;\u8f93\u5165\u7684\u5355\u901a\u9053\u7070\u5ea6\u56fe\u50cf<\/p>\n<\/li>\n<li>\n<p>maxCorners&#061;100&#xff1a;\u8fd4\u56de\u7684\u6700\u5927\u89d2\u70b9\u6570\u91cf&#xff08;\u22640\u8868\u793a\u65e0\u9650\u5236&#xff09;<\/p>\n<\/li>\n<li>\n<p>qualityLevel&#061;0.3&#xff1a;\u89d2\u70b9\u8d28\u91cf\u9608\u503c&#xff08;0-1\u4e4b\u95f4&#xff09;&#xff0c;\u503c\u8d8a\u5927\u68c0\u6d4b\u5230\u7684\u89d2\u70b9\u8d28\u91cf\u8d8a\u9ad8\u4f46\u6570\u91cf\u8d8a\u5c11<\/p>\n<\/li>\n<li>\n<p>minDistance&#061;7&#xff1a;\u89d2\u70b9\u4e4b\u95f4\u7684\u6700\u5c0f\u6b27\u6c0f\u8ddd\u79bb&#xff08;\u50cf\u7d20&#xff09;&#xff0c;\u907f\u514d\u89d2\u70b9\u8fc7\u4e8e\u5bc6\u96c6<\/p>\n<\/li>\n<li>\n<p>mask&#061;None&#xff1a;\u53ef\u9009\u63a9\u7801&#xff0c;\u6307\u5b9a\u68c0\u6d4b\u533a\u57df<\/p>\n<\/li>\n<li>\n<p>blockSize&#061;3&#xff08;\u9ed8\u8ba4&#xff09;&#xff1a;\u8ba1\u7b97\u89d2\u70b9\u65f6\u8003\u8651\u7684\u90bb\u57df\u5927\u5c0f<\/p>\n<\/li>\n<li>\n<p>useHarrisDetector&#061;False&#xff08;\u9ed8\u8ba4&#xff09;&#xff1a;\u662f\u5426\u4f7f\u7528Harris\u89d2\u70b9\u68c0\u6d4b\u5668&#xff08;False\u8868\u793a\u4f7f\u7528Shi-Tomasi&#xff09;<\/p>\n<\/li>\n<\/ul>\n<p>\u8fd4\u56de\u503c&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u89d2\u70b9\u5750\u6807\u6570\u7ec4&#xff0c;\u5f62\u72b6\u4e3a(n, 1, 2)<\/p>\n<\/li>\n<\/ul>\n<h4>2.\u00a0cv2.calcOpticalFlowPyrLK()\u00a0&#8211; Lucas-Kanade\u91d1\u5b57\u5854\u5149\u6d41\u6cd5<\/h4>\n<p>\u8fd9\u662f\u4ee3\u7801\u4e2d\u6838\u5fc3\u7684\u5149\u6d41\u8ba1\u7b97\u51fd\u6570&#xff0c;\u4f7f\u7528\u91d1\u5b57\u5854Lucas-Kanade\u65b9\u6cd5\u3002<\/p>\n<p>\u51fd\u6570\u539f\u578b&#xff1a;<\/p>\n<p>p1, st, err &#061; cv2.calcOpticalFlowPyrLK(<br \/>\n    prevImg&#061;old_gray,<br \/>\n    nextImg&#061;frame_gray,<br \/>\n    prevPts&#061;p0,<br \/>\n    nextPts&#061;None,<br \/>\n    **lk_params<br \/>\n)<\/p>\n<p>\u53c2\u6570\u8be6\u7ec6\u8bf4\u660e&#xff1a;<\/p>\n<h5>\u8f93\u5165\u53c2\u6570&#xff1a;<\/h5>\n<ul>\n<li>\n<p>prevImg&#xff1a;\u524d\u4e00\u5e27\u7684\u7070\u5ea6\u56fe\u50cf<\/p>\n<\/li>\n<li>\n<p>nextImg&#xff1a;\u5f53\u524d\u5e27\u7684\u7070\u5ea6\u56fe\u50cf<\/p>\n<\/li>\n<li>\n<p>prevPts&#xff1a;\u524d\u4e00\u5e27\u4e2d\u9700\u8981\u8ddf\u8e2a\u7684\u7279\u5f81\u70b9\u5750\u6807<\/p>\n<\/li>\n<li>\n<p>nextPts&#xff1a;\u521d\u59cb\u5316\u4e3aNone&#xff0c;\u51fd\u6570\u4f1a\u8ba1\u7b97\u5e76\u8fd4\u56de\u8fd9\u4e9b\u70b9\u5728\u5f53\u524d\u5e27\u4e2d\u7684\u4f4d\u7f6e<\/p>\n<\/li>\n<\/ul>\n<p># Lucas-Kanade\u5149\u6d41\u6cd5\u53c2\u6570<br \/>\nlk_params &#061; dict(<br \/>\n    winSize&#061;(15, 15),  # \u7a97\u53e3\u5927\u5c0f<br \/>\n    maxLevel&#061;2,  # \u91d1\u5b57\u5854\u5c42\u6570<br \/>\n    # criteria&#061;(cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, 10, 0.03)<br \/>\n)<\/p>\n<h5>lk_params\u5b57\u5178\u4e2d\u7684\u53c2\u6570&#xff1a;<\/h5>\n<ul>\n<li>\n<p>winSize&#061;(15, 15)&#xff1a;\u641c\u7d22\u7a97\u53e3\u5927\u5c0f<\/p>\n<ul>\n<li>\n<p>\u8f83\u5927\u7684\u7a97\u53e3\u53ef\u4ee5\u5904\u7406\u66f4\u5927\u7684\u8fd0\u52a8&#xff0c;\u4f46\u8ba1\u7b97\u66f4\u6162<\/p>\n<\/li>\n<li>\n<p>\u8f83\u5c0f\u7684\u7a97\u53e3\u5bf9\u5feb\u901f\u8fd0\u52a8\u654f\u611f\u4f46\u53ef\u80fd\u4e22\u5931\u8ddf\u8e2a<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>maxLevel&#061;2&#xff1a;\u91d1\u5b57\u5854\u5c42\u6570<\/p>\n<ul>\n<li>\n<p>\u91d1\u5b57\u5854\u7528\u4e8e\u5904\u7406\u5927\u4f4d\u79fb\u8fd0\u52a8<\/p>\n<\/li>\n<li>\n<p>\u5c42\u65700\u8868\u793a\u4e0d\u4f7f\u7528\u91d1\u5b57\u5854&#xff0c;\u53ea\u4f7f\u7528\u539f\u59cb\u56fe\u50cf<\/p>\n<\/li>\n<li>\n<p>\u6bcf\u589e\u52a0\u4e00\u5c42&#xff0c;\u56fe\u50cf\u5c3a\u5bf8\u51cf\u534a&#xff0c;\u53ef\u4ee5\u5904\u7406\u66f4\u5927\u7684\u8fd0\u52a8<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>criteria&#xff08;\u4ee3\u7801\u4e2d\u5df2\u6ce8\u91ca&#xff09;&#xff1a;\u8fed\u4ee3\u7ec8\u6b62\u51c6\u5219<\/p>\n<ul>\n<li>\n<p>\u4f8b\u5982&#xff1a;(cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, 10, 0.03)<\/p>\n<\/li>\n<li>\n<p>\u8868\u793a\u6700\u5927\u8fed\u4ee3\u6b21\u657010\u6216\u53d8\u5316\u5c0f\u4e8e0.03\u65f6\u505c\u6b62<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h5>\u53ef\u9009\u53c2\u6570&#xff08;\u4ee3\u7801\u4e2d\u672a\u4f7f\u7528&#xff09;&#xff1a;<\/h5>\n<ul>\n<li>\n<p>flags&#xff1a;\u8ba1\u7b97\u9009\u9879<\/p>\n<ul>\n<li>\n<p>0&#xff1a;\u666e\u901a\u65b9\u6cd5<\/p>\n<\/li>\n<li>\n<p>cv2.OPTFLOW_LK_GET_MIN_EIGENVALS&#xff1a;\u4f7f\u7528\u6700\u5c0f\u7279\u5f81\u503c<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>minEigThreshold&#xff1a;\u7279\u5f81\u503c\u9608\u503c&#xff0c;\u7528\u4e8e\u5224\u65ad\u8ddf\u8e2a\u8d28\u91cf<\/p>\n<\/li>\n<\/ul>\n<p>\u8fd4\u56de\u503c&#xff1a;<\/p>\n<ul>\n<li>\n<p>p1&#xff1a;\u5f53\u524d\u5e27\u4e2d\u4f30\u8ba1\u7684\u7279\u5f81\u70b9\u4f4d\u7f6e<\/p>\n<\/li>\n<li>\n<p>st&#xff1a;\u72b6\u6001\u5411\u91cf&#xff08;\u4e0ep0\u540c\u5927\u5c0f&#xff09;<\/p>\n<ul>\n<li>\n<p>1&#xff1a;\u6210\u529f\u8ddf\u8e2a<\/p>\n<\/li>\n<li>\n<p>0&#xff1a;\u8ddf\u8e2a\u5931\u8d25<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>err&#xff1a;\u8bef\u5dee\u5411\u91cf&#xff0c;\u8868\u793a\u6bcf\u4e2a\u70b9\u7684\u8ddf\u8e2a\u8bef\u5dee<\/p>\n<\/li>\n<\/ul>\n<h3>\u4e09\u3001\u7b97\u6cd5\u6d41\u7a0b\u89e3\u6790<\/h3>\n<h4>1.\u00a0\u521d\u59cb\u5316\u9636\u6bb5<\/h4>\n<p># \u8bfb\u53d6\u7b2c\u4e00\u5e27\u5e76\u8f6c\u4e3a\u7070\u5ea6<br \/>\nold_gray &#061; cv2.cvtColor(old_frame, cv2.COLOR_BGR2GRAY)<\/p>\n<p># \u68c0\u6d4b\u89d2\u70b9\u4f5c\u4e3a\u7279\u5f81\u70b9<br \/>\np0 &#061; cv2.goodFeaturesToTrack(old_gray, maxCorners&#061;100, qualityLevel&#061;0.3, minDistance&#061;7)<\/p>\n<h4>2.\u00a0\u5149\u6d41\u8ba1\u7b97\u5faa\u73af<\/h4>\n<p>    p1, st, err &#061; cv2.calcOpticalFlowPyrLK(prevImg&#061;old_gray, nextImg&#061;frame_gray,prevPts&#061;p0,nextPts&#061;None,**lk_params)<\/p>\n<p>    # \u9009\u62e9\u6210\u529f\u7684\u70b9&#xff08;\u72b6\u6001\u4e3a1\u7684\u70b9&#xff09;<br \/>\n    good_new &#061; p1[st &#061;&#061; 1]<br \/>\n    good_old &#061; p0[st &#061;&#061; 1]<\/p>\n<p>    # \u7ed8\u5236\u8f68\u8ff9<br \/>\n    for i, (new, old) in enumerate(zip(good_new, good_old)):<br \/>\n        # \u83b7\u53d6\u65b0\u70b9\u548c\u65e7\u70b9\u7684\u5750\u6807<br \/>\n        a, b &#061; new  # \u65b0\u70b9\u5750\u6807<br \/>\n        c, d &#061; old  # \u65e7\u70b9\u5750\u6807<\/p>\n<p>        # \u8f6c\u6362\u4e3a\u6574\u6570<br \/>\n        a, b, c, d &#061; int(a), int(b), int(c), int(d)<\/p>\n<p>        # \u5728\u63a9\u6a21\u4e0a\u7ed8\u5236\u7ebf\u6bb5&#xff0c;\u8fde\u63a5\u65b0\u70b9\u548c\u65e7\u70b9<br \/>\n        mask &#061; cv2.line(mask, (a, b), (c, d),<br \/>\n                        color[i].tolist(), thickness&#061;2)<br \/>\n        # \u663e\u793a\u63a9\u6a21<br \/>\n        cv2.imshow(&#039;mask&#039;, mask)<\/p>\n<p>  # \u5c06\u63a9\u6a21\u6dfb\u52a0\u5230\u5f53\u524d\u5e27\u4e0a&#xff0c;\u751f\u6210\u6700\u7ec8\u56fe\u50cf<br \/>\n    img &#061; cv2.add(frame, mask)<\/p>\n<p>    # \u663e\u793a\u56fe\u50cf<br \/>\n    cv2.imshow(&#039;frame&#039;, img)<\/p>\n<p>    # \u7b49\u5f8530ms&#xff0c;\u68c0\u6d4b\u662f\u5426\u6309\u4e0b\u4e86Esc\u952e&#xff08;\u952e\u7801\u4e3a27&#xff09;<br \/>\n    key &#061; cv2.waitKey(30)<br \/>\n    if key &#061;&#061; 27:  # \u6309\u4e0bEsc\u952e&#xff0c;\u9000\u51fa\u5faa\u73af<br \/>\n        break<\/p>\n<p>    # \u66f4\u65b0\u7070\u5ea6\u56fe\u548c\u7279\u5f81\u70b9<br \/>\n    old_gray &#061; frame_gray.copy()<br \/>\n    p0 &#061; good_new.reshape(-1, 1, 2) <\/p>\n<h3>\u56db\u3001\u91d1\u5b57\u5854Lucas-Kanade\u7b97\u6cd5\u539f\u7406<\/h3>\n<h4>1.\u00a0\u57fa\u672cLucas-Kanade\u65b9\u7a0b<\/h4>\n<p>\u5bf9\u4e8e\u6bcf\u4e2a\u7279\u5f81\u70b9&#xff0c;\u5047\u8bbe\u5728\u4e00\u4e2a\u5c0f\u7684\u90bb\u57df\u7a97\u53e3\u5185&#xff0c;\u6240\u6709\u50cf\u7d20\u5177\u6709\u76f8\u540c\u7684\u8fd0\u52a8&#xff1a;<\/p>\n<p>I(x,y,t) &#061; I(x&#043;dx, y&#043;dy, t&#043;dt)<\/p>\n<p>\u901a\u8fc7\u6cf0\u52d2\u5c55\u5f00\u5f97\u5230\u5149\u6d41\u65b9\u7a0b&#xff1a;<\/p>\n<p>I_x * u &#043; I_y * v &#043; I_t &#061; 0<\/p>\n<p>\u5176\u4e2d&#xff1a;<\/p>\n<ul>\n<li>\n<p>I_x, I_y&#xff1a;\u56fe\u50cf\u5728x,y\u65b9\u5411\u7684\u68af\u5ea6<\/p>\n<\/li>\n<li>\n<p>I_t&#xff1a;\u65f6\u95f4\u68af\u5ea6<\/p>\n<\/li>\n<li>\n<p>u, v&#xff1a;x,y\u65b9\u5411\u7684\u901f\u5ea6<\/p>\n<\/li>\n<\/ul>\n<h4>2.\u00a0\u91d1\u5b57\u5854\u65b9\u6cd5<\/h4>\n<ul>\n<li>\n<p>\u6784\u5efa\u56fe\u50cf\u91d1\u5b57\u5854&#xff1a;\u4ece\u539f\u59cb\u56fe\u50cf\u5f00\u59cb&#xff0c;\u6bcf\u5c42\u5c3a\u5bf8\u51cf\u534a<\/p>\n<\/li>\n<li>\n<p>\u4ece\u9876\u5c42\u5f00\u59cb\u8ba1\u7b97&#xff1a;\u5728\u4f4e\u5206\u8fa8\u7387\u5c42\u8ba1\u7b97\u7c97\u7565\u5149\u6d41<\/p>\n<\/li>\n<li>\n<p>\u9010\u5c42\u7ec6\u5316&#xff1a;\u5c06\u7c97\u7565\u7ed3\u679c\u4f5c\u4e3a\u4e0b\u4e00\u5c42\u7684\u521d\u59cb\u503c<\/p>\n<\/li>\n<li>\n<p>\u6700\u7ec8\u5728\u539f\u59cb\u5206\u8fa8\u7387\u5c42\u5f97\u5230\u7cbe\u786e\u7ed3\u679c<\/p>\n<\/li>\n<\/ul>\n<h4>3.\u00a0\u7a97\u53e3\u641c\u7d22<\/h4>\n<p>\u5bf9\u4e8e\u6bcf\u4e2a\u7279\u5f81\u70b9&#xff0c;\u5728\u5176\u5468\u56f4\u7684winSize\u7a97\u53e3\u5185\u641c\u7d22\u6700\u4f73\u5339\u914d\u4f4d\u7f6e\u3002<\/p>\n<h3>\u4e94\u3001\u5e94\u7528\u573a\u666f<\/h3>\n<li>\n<p>\u8fd0\u52a8\u68c0\u6d4b\u4e0e\u5206\u6790<\/p>\n<\/li>\n<li>\n<p>\u89c6\u9891\u7a33\u5b9a<\/p>\n<\/li>\n<li>\n<p>\u76ee\u6807\u8ddf\u8e2a<\/p>\n<\/li>\n<li>\n<p>\u52a8\u4f5c\u8bc6\u522b<\/p>\n<\/li>\n<li>\n<p>\u4e09\u7ef4\u91cd\u5efa<\/p>\n<\/li>\n<li>\n<p>\u81ea\u52a8\u9a7e\u9a76&#xff08;\u8f66\u8f86\/\u884c\u4eba\u8fd0\u52a8\u4f30\u8ba1&#xff09;<\/p>\n<\/li>\n<h3>\u516d\u3001\u4f18\u7f3a\u70b9<\/h3>\n<h4>\u4f18\u70b9&#xff1a;<\/h4>\n<ul>\n<li>\n<p>\u8ba1\u7b97\u6548\u7387\u9ad8&#xff0c;\u9002\u5408\u5b9e\u65f6\u5e94\u7528<\/p>\n<\/li>\n<li>\n<p>\u5bf9\u4eae\u5ea6\u53d8\u5316\u6709\u4e00\u5b9a\u9c81\u68d2\u6027<\/p>\n<\/li>\n<li>\n<p>\u91d1\u5b57\u5854\u7ed3\u6784\u53ef\u4ee5\u5904\u7406\u8f83\u5927\u4f4d\u79fb<\/p>\n<\/li>\n<\/ul>\n<h4>\u5c40\u9650\u6027&#xff1a;<\/h4>\n<ul>\n<li>\n<p>\u4f9d\u8d56\u4e8e\u4eae\u5ea6\u6052\u5b9a\u5047\u8bbe<\/p>\n<\/li>\n<li>\n<p>\u5bf9\u5feb\u901f\u8fd0\u52a8\u6216\u906e\u6321\u5904\u7406\u4e0d\u4f73<\/p>\n<\/li>\n<li>\n<p>\u9700\u8981\u597d\u7684\u7279\u5f81\u70b9&#xff08;\u89d2\u70b9&#xff09;<\/p>\n<\/li>\n<\/ul>\n<h3>\u4e03\u3001\u5b9e\u9645\u8fd0\u7528<\/h3>\n<p>import cv2<br \/>\nimport numpy as np<\/p>\n<p># \u8bfb\u53d6\u89c6\u9891\u6587\u4ef6<br \/>\ncap &#061; cv2.VideoCapture(&#039;renwushipin.avi&#039;)<\/p>\n<p># \u8bfb\u53d6\u7b2c\u4e00\u5e27<br \/>\nret, old_frame &#061; cap.read()<\/p>\n<p># \u8f6c\u6362\u4e3a\u7070\u5ea6\u56fe\u50cf<br \/>\nold_gray &#061; cv2.cvtColor(old_frame, cv2.COLOR_BGR2GRAY)<\/p>\n<p># Shi-Tomasi\u89d2\u70b9\u68c0\u6d4b\u53c2\u6570<br \/>\nfeature_params &#061; dict(<br \/>\n    maxCorners&#061;100,  # \u6700\u5927\u89d2\u70b9\u6570\u91cf<br \/>\n    qualityLevel&#061;0.3,  # \u89d2\u70b9\u8d28\u91cf\u7684\u9608\u503c<br \/>\n    minDistance&#061;7  # \u6700\u5c0f\u8ddd\u79bb&#xff0c;\u7528\u4e8e\u5206\u6563\u89d2\u70b9<br \/>\n)<\/p>\n<p># Shi-Tomasi\u89d2\u70b9\u68c0\u6d4b<br \/>\np0 &#061; cv2.goodFeaturesToTrack(image&#061;old_gray,mask&#061;None,**feature_params)<\/p>\n<p># \u521b\u5efa\u7528\u4e8e\u7ed8\u5236\u8f68\u8ff9\u7684\u63a9\u6a21<br \/>\nmask &#061; np.zeros_like(old_frame)<\/p>\n<p># Lucas-Kanade\u5149\u6d41\u6cd5\u53c2\u6570<br \/>\nlk_params &#061; dict(<br \/>\n    winSize&#061;(15, 15),  # \u7a97\u53e3\u5927\u5c0f<br \/>\n    maxLevel&#061;2,  # \u91d1\u5b57\u5854\u5c42\u6570<br \/>\n    # criteria&#061;(cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, 10, 0.03)<br \/>\n)<br \/>\n# \u751f\u6210\u968f\u673a\u989c\u8272\u7528\u4e8e\u7ed8\u5236\u8f68\u8ff9<br \/>\ncolor &#061; np.random.randint(0, 255, (100, 3))<\/p>\n<p>while True:<br \/>\n    # \u8bfb\u53d6\u4e0b\u4e00\u5e27<br \/>\n    ret, frame &#061; cap.read()<br \/>\n    if not ret:<br \/>\n        break<\/p>\n<p>    # \u8f6c\u6362\u4e3a\u7070\u5ea6\u56fe<br \/>\n    frame_gray &#061; cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)<\/p>\n<p>    # \u8ba1\u7b97\u5149\u6d41<br \/>\n    p1, st, err &#061; cv2.calcOpticalFlowPyrLK(prevImg&#061;old_gray, nextImg&#061;frame_gray,prevPts&#061;p0,nextPts&#061;None,**lk_params)<\/p>\n<p>    # \u9009\u62e9\u6210\u529f\u7684\u70b9&#xff08;\u72b6\u6001\u4e3a1\u7684\u70b9&#xff09;<br \/>\n    good_new &#061; p1[st &#061;&#061; 1]<br \/>\n    good_old &#061; p0[st &#061;&#061; 1]<\/p>\n<p>    # \u7ed8\u5236\u8f68\u8ff9<br \/>\n    for i, (new, old) in enumerate(zip(good_new, good_old)):<br \/>\n        # \u83b7\u53d6\u65b0\u70b9\u548c\u65e7\u70b9\u7684\u5750\u6807<br \/>\n        a, b &#061; new  # \u65b0\u70b9\u5750\u6807<br \/>\n        c, d &#061; old  # \u65e7\u70b9\u5750\u6807<\/p>\n<p>        # \u8f6c\u6362\u4e3a\u6574\u6570<br \/>\n        a, b, c, d &#061; int(a), int(b), int(c), int(d)<\/p>\n<p>        # \u5728\u63a9\u6a21\u4e0a\u7ed8\u5236\u7ebf\u6bb5&#xff0c;\u8fde\u63a5\u65b0\u70b9\u548c\u65e7\u70b9<br \/>\n        mask &#061; cv2.line(mask, (a, b), (c, d),<br \/>\n                        color[i].tolist(), thickness&#061;2)<br \/>\n        # \u663e\u793a\u63a9\u6a21<br \/>\n        cv2.imshow(&#039;mask&#039;, mask)<\/p>\n<p>  # \u5c06\u63a9\u6a21\u6dfb\u52a0\u5230\u5f53\u524d\u5e27\u4e0a&#xff0c;\u751f\u6210\u6700\u7ec8\u56fe\u50cf<br \/>\n    img &#061; cv2.add(frame, mask)<\/p>\n<p>    # \u663e\u793a\u56fe\u50cf<br \/>\n    cv2.imshow(&#039;frame&#039;, img)<\/p>\n<p>    # \u7b49\u5f8530ms&#xff0c;\u68c0\u6d4b\u662f\u5426\u6309\u4e0b\u4e86Esc\u952e&#xff08;\u952e\u7801\u4e3a27&#xff09;<br \/>\n    key &#061; cv2.waitKey(30)<br \/>\n    if key &#061;&#061; 27:  # \u6309\u4e0bEsc\u952e&#xff0c;\u9000\u51fa\u5faa\u73af<br \/>\n        break<\/p>\n<p>    # \u66f4\u65b0\u7070\u5ea6\u56fe\u548c\u7279\u5f81\u70b9<br \/>\n    old_gray &#061; frame_gray.copy()<br \/>\n    p0 &#061; good_new.reshape(-1, 1, 2)  # \u91cd\u65b0\u6574\u7406\u7279\u5f81\u70b9\u4e3a\u9002\u5408\u4e0b\u6b21\u8ba1\u7b97\u7684\u5f62\u72b6&#xff08;n,2&#xff09;-&gt;&#xff08;n,1,2&#xff09;<\/p>\n<p># \u91ca\u653e\u8d44\u6e90<br \/>\ncap.release()<br \/>\ncv2.destroyAllWindows()<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"756\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260131142450-697e10b215397.png\" width=\"1906\" \/><\/p>\n<p>\u8fd9\u4e2a\u4ee3\u7801\u793a\u4f8b\u5b8c\u6574\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528OpenCV\u5b9e\u73b0\u57fa\u4e8e\u7279\u5f81\u70b9\u7684\u5149\u6d41\u8ddf\u8e2a&#xff0c;\u5305\u62ec\u7279\u5f81\u70b9\u68c0\u6d4b\u3001\u5149\u6d41\u8ba1\u7b97\u3001\u8f68\u8ff9\u7ed8\u5236\u7b49\u5b8c\u6574\u6d41\u7a0b\u3002\u4ece\u4ee3\u7801\u4f17&#xff0c;\u53ef\u4ee5\u770b\u5230&#xff0c;\u8fd9\u4e2a\u4ee3\u7801\u4f7f\u7528\u7684\u662f\u89c6\u9891&#xff0c;\u548c\u4e4b\u524d\u4f7f\u7528\u56fe\u7247\u65f6\u7684\u4ee3\u7801\u8bfb\u53d6\u65b9\u5f0f\u6709\u6240\u4e0d\u540c&#xff0c;\u90a3\u4e48\u6709\u4ec0\u4e48\u4e0d\u540c\u5462&#xff1f;<\/p>\n<h3>\u516b\u3001\u89c6\u9891\u8bfb\u53d6\u65b9\u6cd5\u53ca\u4e0e\u56fe\u7247\u7684\u533a\u522b<\/h3>\n<h4>1.\u89c6\u9891\u8bfb\u53d6\u7684\u8be6\u7ec6\u673a\u5236<\/h4>\n<h5>1&#xff09;\u00a0VideoCapture\u5bf9\u8c61<\/h5>\n<p># \u521b\u5efa\u89c6\u9891\u6355\u83b7\u5bf9\u8c61<br \/>\ncap &#061; cv2.VideoCapture(&#039;renwushipin.avi&#039;)<br \/>\n# \u6216\u4ece\u6444\u50cf\u5934\u8bfb\u53d6<br \/>\n# cap &#061; cv2.VideoCapture(0)  # 0\u8868\u793a\u9ed8\u8ba4\u6444\u50cf\u5934<\/p>\n<p>\u5173\u952e\u5c5e\u6027\u548c\u65b9\u6cd5&#xff1a;<\/p>\n<ul>\n<li>\n<p>cap.isOpened(): \u68c0\u67e5\u662f\u5426\u6210\u529f\u6253\u5f00<\/p>\n<\/li>\n<li>\n<p>cap.get(propId): \u83b7\u53d6\u89c6\u9891\u5c5e\u6027&#xff08;\u5e27\u7387\u3001\u5c3a\u5bf8\u7b49&#xff09;<\/p>\n<\/li>\n<li>\n<p>cap.set(propId, value): \u8bbe\u7f6e\u89c6\u9891\u5c5e\u6027<\/p>\n<\/li>\n<\/ul>\n<h5>2&#xff09;\u9010\u5e27\u8bfb\u53d6\u5faa\u73af<\/h5>\n<p>while True:<br \/>\n    # \u8bfb\u53d6\u4e00\u5e27<br \/>\n    ret, frame &#061; cap.read()<\/p>\n<p>    # ret: \u5e03\u5c14\u503c&#xff0c;\u8868\u793a\u662f\u5426\u6210\u529f\u8bfb\u53d6<br \/>\n    # frame: \u5f53\u524d\u5e27\u7684\u56fe\u50cf\u6570\u636e&#xff08;numpy\u6570\u7ec4&#xff09;<\/p>\n<p>    if not ret:  # \u89c6\u9891\u7ed3\u675f\u6216\u8bfb\u53d6\u5931\u8d25<br \/>\n        break<\/p>\n<p>    # \u5904\u7406\u5f53\u524d\u5e27&#xff08;\u5149\u6d41\u8ba1\u7b97\u3001\u663e\u793a\u7b49&#xff09;<\/p>\n<h4>2. \u5bf9\u6bd4<\/h4>\n<h5>1&#xff09;\u6570\u636e\u7ed3\u6784\u4e0d\u540c<\/h5>\n<p># \u89c6\u9891\u8bfb\u53d6 &#8211; \u8fde\u7eed\u5e27\u5e8f\u5217<br \/>\ncap &#061; cv2.VideoCapture(&#039;video.avi&#039;)<br \/>\nret, frame &#061; cap.read()  # \u6bcf\u6b21\u8bfb\u53d6\u4e00\u5e27<\/p>\n<p># \u56fe\u7247\u8bfb\u53d6 &#8211; \u5355\u5f20\u56fe\u50cf<br \/>\nimg &#061; cv2.imread(&#039;image.jpg&#039;)  # \u4e00\u6b21\u6027\u8bfb\u53d6\u6574\u4e2a\u56fe\u50cf<\/p>\n<p>\u5982\u679c\u60f3\u4f7f\u7528\u6444\u50cf\u5934&#xff0c;\u53ea\u9700\u8981\u5c06cap &#061; cv2.VideoCapture(&#039;video.avi&#039;)\u6539\u4e3acap &#061; cv2.VideoCapture(0)<\/p>\n<h5>2&#xff09;\u00a0\u8bfb\u53d6\u65b9\u5f0f\u4e0d\u540c<\/h5>\n<p># \u89c6\u9891 &#8211; \u5faa\u73af\u9010\u5e27\u8bfb\u53d6<br \/>\nwhile True:<br \/>\n    ret, frame &#061; cap.read()  # \u9700\u8981\u624b\u52a8\u63a7\u5236\u8bfb\u53d6<br \/>\n    if not ret:  # \u68c0\u67e5\u662f\u5426\u8bfb\u53d6\u6210\u529f<br \/>\n        break<br \/>\n    # \u5904\u7406\u6bcf\u4e00\u5e27<\/p>\n<p># \u56fe\u7247 &#8211; \u4e00\u6b21\u6027\u8bfb\u53d6<br \/>\nimg &#061; cv2.imread(&#039;image.jpg&#039;)  # \u5355\u6b21\u8c03\u7528\u8bfb\u53d6\u6240\u6709\u6570\u636e<\/p>\n<h4>3.\u5728\u5149\u6d41\u4f30\u8ba1\u4e2d\u7684\u7279\u6b8a\u610f\u4e49<\/h4>\n<h5>1&#xff09;\u00a0\u65f6\u95f4\u8fde\u7eed\u6027\u8981\u6c42<\/h5>\n<p># \u5149\u6d41\u9700\u8981\u8fde\u7eed\u5e27\u7684\u65f6\u95f4\u5e8f\u5217<br \/>\nold_gray &#061; cv2.cvtColor(old_frame, cv2.COLOR_BGR2GRAY)<\/p>\n<p>while True:<br \/>\n    ret, frame &#061; cap.read()<br \/>\n    frame_gray &#061; cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)<\/p>\n<p>    # \u8ba1\u7b97\u76f8\u90bb\u5e27\u4e4b\u95f4\u7684\u8fd0\u52a8<br \/>\n    p1, st, err &#061; cv2.calcOpticalFlowPyrLK(old_gray, frame_gray, p0, None, **lk_params)<\/p>\n<p>    # \u66f4\u65b0\u4e3a\u4e0b\u4e00\u5e27\u51c6\u5907<br \/>\n    old_gray &#061; frame_gray.copy()<\/p>\n<h5>2&#xff09;\u00a0\u7279\u5f81\u70b9\u8ffd\u8e2a\u7684\u6301\u7eed\u6027<\/h5>\n<p># \u9700\u8981\u4fdd\u6301\u7279\u5f81\u70b9\u7684\u8fde\u7eed\u6027<br \/>\np0 &#061; good_new.reshape(-1, 1, 2)  # \u4e3a\u4e0b\u4e00\u5e27\u66f4\u65b0\u7279\u5f81\u70b9<\/p>\n<p># \u5728\u89c6\u9891\u4e2d&#xff0c;\u7279\u5f81\u70b9\u53ef\u4ee5\u6301\u7eed\u8ddf\u8e2a\u591a\u5e27<br \/>\n# \u5728\u9759\u6001\u56fe\u7247\u5bf9\u4e2d&#xff0c;\u53ea\u80fd\u8ba1\u7b97\u5355\u6b21\u8fd0\u52a8<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u5149\u6d41\u4f30\u8ba1\u6982\u5ff5\u5149\u6d41&#xff08;Optical Flow&#xff09;\u00a0\u662f\u8ba1\u7b97\u673a\u89c6\u89c9\u4e2d\u7528\u4e8e\u63cf\u8ff0\u56fe\u50cf\u4e2d\u50cf\u7d20\u70b9\u8fd0\u52a8\u6a21\u5f0f\u7684\u6280\u672f\u3002\u5b83\u57fa\u4e8e\u4ee5\u4e0b\u4e24\u4e2a\u57fa\u672c\u5047\u8bbe&#xff1a;\u4eae\u5ea6\u6052\u5b9a\u5047\u8bbe&#xff1a;\u540c\u4e00\u7269\u4f53\u70b9\u5728\u8fde\u7eed\u5e27\u4e2d\u7684\u4eae\u5ea6\u4fdd\u6301\u4e0d\u53d8\u65f6\u7a7a\u8fde\u7eed\u6027\u5047\u8bbe&#xff1a;\u76f8\u90bb\u70b9\u5177\u6709\u76f8\u4f3c\u7684\u8fd0\u52a8\u5149\u6d41\u4f30\u8ba1\u7684\u6838\u5fc3\u601d\u60f3\u662f&#xff1a;\u5728\u89c6\u9891\u5e8f\u5217\u4e2d&#xff0c;\u901a\u8fc7\u5206\u6790\u76f8\u90bb\u5e27\u4e4b\u95f4\u50cf\u7d20\u5f3a\u5ea6\u7684\u53d8\u5316\u6765\u4f30\u8ba1\u50cf\u7d20\u7684\u8fd0\u52a8\u901f\u5ea6\u548c\u65b9\u5411\u3002\u4e8c\u3001\u51fd\u6570\u8be6\u89e31.\u00a0cv2.goodFeaturesToTrack()\u00a0&#8211; Sh<\/p>\n","protected":false},"author":2,"featured_media":69615,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[7322,7323,7324,1460,82,81,523],"topic":[],"class_list":["post-69616","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-7322","tag-7323","tag-7324","tag-opencv","tag-pycharm","tag-python","tag-523"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>opencv\u8ba1\u7b97\u673a\u89c6\u89c9-\u5149\u6d41\u4f30\u8ba1&amp;\u89c6\u9891\u8bfb\u53d6\u65b9\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/69616.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"opencv\u8ba1\u7b97\u673a\u89c6\u89c9-\u5149\u6d41\u4f30\u8ba1&amp;\u89c6\u9891\u8bfb\u53d6\u65b9\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u3001\u5149\u6d41\u4f30\u8ba1\u6982\u5ff5\u5149\u6d41&#xff08;Optical Flow&#xff09;\u00a0\u662f\u8ba1\u7b97\u673a\u89c6\u89c9\u4e2d\u7528\u4e8e\u63cf\u8ff0\u56fe\u50cf\u4e2d\u50cf\u7d20\u70b9\u8fd0\u52a8\u6a21\u5f0f\u7684\u6280\u672f\u3002\u5b83\u57fa\u4e8e\u4ee5\u4e0b\u4e24\u4e2a\u57fa\u672c\u5047\u8bbe&#xff1a;\u4eae\u5ea6\u6052\u5b9a\u5047\u8bbe&#xff1a;\u540c\u4e00\u7269\u4f53\u70b9\u5728\u8fde\u7eed\u5e27\u4e2d\u7684\u4eae\u5ea6\u4fdd\u6301\u4e0d\u53d8\u65f6\u7a7a\u8fde\u7eed\u6027\u5047\u8bbe&#xff1a;\u76f8\u90bb\u70b9\u5177\u6709\u76f8\u4f3c\u7684\u8fd0\u52a8\u5149\u6d41\u4f30\u8ba1\u7684\u6838\u5fc3\u601d\u60f3\u662f&#xff1a;\u5728\u89c6\u9891\u5e8f\u5217\u4e2d&#xff0c;\u901a\u8fc7\u5206\u6790\u76f8\u90bb\u5e27\u4e4b\u95f4\u50cf\u7d20\u5f3a\u5ea6\u7684\u53d8\u5316\u6765\u4f30\u8ba1\u50cf\u7d20\u7684\u8fd0\u52a8\u901f\u5ea6\u548c\u65b9\u5411\u3002\u4e8c\u3001\u51fd\u6570\u8be6\u89e31.\u00a0cv2.goodFeaturesToTrack()\u00a0- Sh\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/69616.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-31T14:24:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260131142450-697e10b215397.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/69616.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/69616.html\",\"name\":\"opencv\u8ba1\u7b97\u673a\u89c6\u89c9-\u5149\u6d41\u4f30\u8ba1&amp;\u89c6\u9891\u8bfb\u53d6\u65b9\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-31T14:24:52+00:00\",\"dateModified\":\"2026-01-31T14:24:52+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/69616.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/69616.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/69616.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"opencv\u8ba1\u7b97\u673a\u89c6\u89c9--\u5149\u6d41\u4f30\u8ba1&amp;\u89c6\u9891\u8bfb\u53d6\u65b9\u6cd5\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"opencv\u8ba1\u7b97\u673a\u89c6\u89c9-\u5149\u6d41\u4f30\u8ba1&amp;\u89c6\u9891\u8bfb\u53d6\u65b9\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/69616.html","og_locale":"zh_CN","og_type":"article","og_title":"opencv\u8ba1\u7b97\u673a\u89c6\u89c9-\u5149\u6d41\u4f30\u8ba1&amp;\u89c6\u9891\u8bfb\u53d6\u65b9\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e00\u3001\u5149\u6d41\u4f30\u8ba1\u6982\u5ff5\u5149\u6d41&#xff08;Optical Flow&#xff09;\u00a0\u662f\u8ba1\u7b97\u673a\u89c6\u89c9\u4e2d\u7528\u4e8e\u63cf\u8ff0\u56fe\u50cf\u4e2d\u50cf\u7d20\u70b9\u8fd0\u52a8\u6a21\u5f0f\u7684\u6280\u672f\u3002\u5b83\u57fa\u4e8e\u4ee5\u4e0b\u4e24\u4e2a\u57fa\u672c\u5047\u8bbe&#xff1a;\u4eae\u5ea6\u6052\u5b9a\u5047\u8bbe&#xff1a;\u540c\u4e00\u7269\u4f53\u70b9\u5728\u8fde\u7eed\u5e27\u4e2d\u7684\u4eae\u5ea6\u4fdd\u6301\u4e0d\u53d8\u65f6\u7a7a\u8fde\u7eed\u6027\u5047\u8bbe&#xff1a;\u76f8\u90bb\u70b9\u5177\u6709\u76f8\u4f3c\u7684\u8fd0\u52a8\u5149\u6d41\u4f30\u8ba1\u7684\u6838\u5fc3\u601d\u60f3\u662f&#xff1a;\u5728\u89c6\u9891\u5e8f\u5217\u4e2d&#xff0c;\u901a\u8fc7\u5206\u6790\u76f8\u90bb\u5e27\u4e4b\u95f4\u50cf\u7d20\u5f3a\u5ea6\u7684\u53d8\u5316\u6765\u4f30\u8ba1\u50cf\u7d20\u7684\u8fd0\u52a8\u901f\u5ea6\u548c\u65b9\u5411\u3002\u4e8c\u3001\u51fd\u6570\u8be6\u89e31.\u00a0cv2.goodFeaturesToTrack()\u00a0- Sh","og_url":"https:\/\/www.wsisp.com\/helps\/69616.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-31T14:24:52+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260131142450-697e10b215397.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/69616.html","url":"https:\/\/www.wsisp.com\/helps\/69616.html","name":"opencv\u8ba1\u7b97\u673a\u89c6\u89c9-\u5149\u6d41\u4f30\u8ba1&amp;\u89c6\u9891\u8bfb\u53d6\u65b9\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-31T14:24:52+00:00","dateModified":"2026-01-31T14:24:52+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/69616.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/69616.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/69616.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"opencv\u8ba1\u7b97\u673a\u89c6\u89c9--\u5149\u6d41\u4f30\u8ba1&amp;\u89c6\u9891\u8bfb\u53d6\u65b9\u6cd5"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/69616","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=69616"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/69616\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/69615"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=69616"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=69616"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=69616"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=69616"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}