{"id":66998,"date":"2026-01-28T00:04:45","date_gmt":"2026-01-27T16:04:45","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/66998.html"},"modified":"2026-01-28T00:04:45","modified_gmt":"2026-01-27T16:04:45","slug":"opencv%e5%ae%9e%e6%88%98%ef%bc%9adnn%e9%a3%8e%e6%a0%bc%e8%bf%81%e7%a7%bb%e4%b8%8ecsrt%e7%89%a9%e4%bd%93%e8%bf%bd%e8%b8%aa","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/66998.html","title":{"rendered":"OpenCV\u5b9e\u6218\uff1aDNN\u98ce\u683c\u8fc1\u79fb\u4e0eCSRT\u7269\u4f53\u8ffd\u8e2a"},"content":{"rendered":"<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"%E4%B8%80%E3%80%81DNN%E9%A3%8E%E6%A0%BC%E8%BF%81%E7%A7%BB%EF%BC%9A%E5%8E%9F%E7%90%86%E4%B8%8E%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0-toc\" style=\"margin-left:0px\">\u4e00\u3001DNN\u98ce\u683c\u8fc1\u79fb&#xff1a;\u539f\u7406\u4e0e\u4ee3\u7801\u5b9e\u73b0<\/p>\n<p id=\"1.%20%E6%A0%B8%E5%BF%83%E5%8E%9F%E7%90%86-toc\" style=\"margin-left:40px\">1. \u6838\u5fc3\u539f\u7406<\/p>\n<p id=\"2.%20%E5%AE%9E%E6%88%98%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0-toc\" style=\"margin-left:40px\">2. \u5b9e\u6218\u4ee3\u7801\u5b9e\u73b0<\/p>\n<p id=\"3.%20%E5%85%B3%E9%94%AE%E5%87%BD%E6%95%B0%E8%A7%A3%E6%9E%90-toc\" style=\"margin-left:40px\">3. \u5173\u952e\u51fd\u6570\u89e3\u6790<\/p>\n<p id=\"%E4%BA%8C%E3%80%81CSRT%E7%89%A9%E4%BD%93%E8%BF%BD%E8%B8%AA%EF%BC%9A%E5%8E%9F%E7%90%86%E4%B8%8E%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0-toc\" style=\"margin-left:0px\">\u4e8c\u3001CSRT\u7269\u4f53\u8ffd\u8e2a&#xff1a;\u539f\u7406\u4e0e\u4ee3\u7801\u5b9e\u73b0<\/p>\n<p id=\"1.%20%E6%A0%B8%E5%BF%83%E5%8E%9F%E7%90%86-toc\" style=\"margin-left:40px\">1. \u6838\u5fc3\u539f\u7406<\/p>\n<p id=\"2.%20%E5%AE%9E%E6%88%98%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0-toc\" style=\"margin-left:40px\">2. \u5b9e\u6218\u4ee3\u7801\u5b9e\u73b0<\/p>\n<p id=\"3.%20%E5%85%B3%E9%94%AE%E5%87%BD%E6%95%B0%E8%A7%A3%E6%9E%90-toc\" style=\"margin-left:40px\">3. \u5173\u952e\u51fd\u6570\u89e3\u6790<\/p>\n<p id=\"%E4%B8%89%E3%80%81%E4%B8%A4%E8%80%85%E6%95%B4%E5%90%88%EF%BC%9A%E5%AE%9E%E6%97%B6%E9%A3%8E%E6%A0%BC%E8%BF%81%E7%A7%BB%2B%E7%89%A9%E4%BD%93%E8%BF%BD%E8%B8%AA-toc\" style=\"margin-left:0px\">\u4e09\u3001\u4e24\u8005\u6574\u5408&#xff1a;\u5b9e\u65f6\u98ce\u683c\u8fc1\u79fb&#043;\u7269\u4f53\u8ffd\u8e2a<\/p>\n<p id=\"1.%20%E6%95%B4%E5%90%88%E6%A0%B8%E5%BF%83%E9%80%BB%E8%BE%91-toc\" style=\"margin-left:40px\">1. \u6574\u5408\u6838\u5fc3\u903b\u8f91<\/p>\n<p id=\"2.%20%E6%95%B4%E5%90%88%E5%90%8E%E5%AE%8C%E6%95%B4%E4%BB%A3%E7%A0%81-toc\" style=\"margin-left:40px\">2. \u6574\u5408\u540e\u5b8c\u6574\u4ee3\u7801<\/p>\n<p id=\"3.%20%E6%95%B4%E5%90%88%E5%85%B3%E9%94%AE%E4%BC%98%E5%8C%96%E7%82%B9-toc\" style=\"margin-left:40px\">3. \u6574\u5408\u5173\u952e\u4f18\u5316\u70b9<\/p>\n<p id=\"%E5%9B%9B%E3%80%81%E5%AE%9E%E6%88%98%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9-toc\" style=\"margin-left:0px\">\u56db\u3001\u5b9e\u6218\u6ce8\u610f\u4e8b\u9879<\/p>\n<hr id=\"hr-toc\" \/>\n<p>\u5728\u8ba1\u7b97\u673a\u89c6\u89c9\u5b9e\u6218\u4e2d&#xff0c;\u5c06\u98ce\u683c\u8fc1\u79fb\u4e0e\u7269\u4f53\u8ffd\u8e2a\u7ed3\u5408\u53ef\u5b9e\u73b0\u66f4\u5177\u89c6\u89c9\u51b2\u51fb\u529b\u7684\u6548\u679c\u3002\u672c\u6587\u57fa\u4e8eOpenCV&#xff0c;\u4ece\u539f\u7406\u5230\u4ee3\u7801\u9010\u6a21\u5757\u62c6\u89e3&#xff0c;\u6700\u7ec8\u5b9e\u73b0\u201c\u5b9e\u65f6\u98ce\u683c\u8fc1\u79fb&#043;\u76ee\u6807\u8ffd\u8e2a\u201d\u7684\u878d\u5408\u65b9\u6848&#xff0c;\u5168\u7a0b\u805a\u7126\u5b9e\u64cd&#xff0c;\u4e0d\u5806\u780c\u5197\u4f59\u7406\u8bba\u3002<\/p>\n<h2 id=\"%E4%B8%80%E3%80%81DNN%E9%A3%8E%E6%A0%BC%E8%BF%81%E7%A7%BB%EF%BC%9A%E5%8E%9F%E7%90%86%E4%B8%8E%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0\">\u4e00\u3001DNN\u98ce\u683c\u8fc1\u79fb&#xff1a;\u539f\u7406\u4e0e\u4ee3\u7801\u5b9e\u73b0<\/h2>\n<h3 id=\"1.%20%E6%A0%B8%E5%BF%83%E5%8E%9F%E7%90%86\">1. \u6838\u5fc3\u539f\u7406<\/h3>\n<p>DNN&#xff08;Deep Neural Network&#xff0c;\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc&#xff09;\u662f\u6df1\u5ea6\u5b66\u4e60\u7684\u6838\u5fc3\u8f7d\u4f53&#xff0c;\u901a\u8fc7\u591a\u5c42\u795e\u7ecf\u5143\u6a21\u62df\u4eba\u8111\u7ed3\u6784&#xff0c;\u5b9e\u73b0\u4ece\u6570\u636e\u4e2d\u81ea\u52a8\u63d0\u53d6\u7279\u5f81\u3001\u5b8c\u6210\u590d\u6742\u4efb\u52a1&#xff08;\u5982\u56fe\u50cf\u8bc6\u522b\u3001\u98ce\u683c\u8fc1\u79fb&#xff09;\u3002\u4e0e\u4f20\u7edf\u6d45\u5c42\u7f51\u7edc\u76f8\u6bd4&#xff0c;DNN\u51ed\u501f\u6df1\u5c42\u7ed3\u6784\u53ef\u6355\u6349\u66f4\u62bd\u8c61\u7684\u7279\u5f81&#xff0c;\u5728\u8ba1\u7b97\u673a\u89c6\u89c9\u9886\u57df\u4e2d&#xff0c;\u9884\u8bad\u7ec3DNN\u6a21\u578b\u80fd\u8df3\u8fc7\u7e41\u7410\u7684\u7279\u5f81\u5de5\u7a0b&#xff0c;\u76f4\u63a5\u7528\u4e8e\u63a8\u7406\u90e8\u7f72&#xff0c;\u672c\u6587\u98ce\u683c\u8fc1\u79fb\u6b63\u662f\u57fa\u4e8e\u9884\u8bad\u7ec3DNN\u6a21\u578b\u5feb\u901f\u5b9e\u73b0\u3002<\/p>\n<p>\u57fa\u4e8e\u9884\u8bad\u7ec3DNN\u6a21\u578b\u7684\u98ce\u683c\u8fc1\u79fb&#xff0c;\u672c\u8d28\u662f\u901a\u8fc7\u795e\u7ecf\u7f51\u7edc\u63d0\u53d6\u8f93\u5165\u56fe\u50cf\u7684\u5185\u5bb9\u7279\u5f81\u4e0e\u98ce\u683c\u56fe\u50cf\u7684\u98ce\u683c\u7279\u5f81&#xff0c;\u518d\u878d\u5408\u751f\u6210\u65b0\u56fe\u50cf\u3002\u672c\u6587\u76f4\u63a5\u4f7f\u7528\u9884\u8bad\u7ec3\u7684&#096;.t7&#096;\u6a21\u578b&#xff08;\u57fa\u4e8eTorch\u6846\u67b6\u8bad\u7ec3&#xff09;&#xff0c;\u8df3\u8fc7\u8bad\u7ec3\u73af\u8282&#xff0c;\u4e13\u6ce8\u63a8\u7406\u90e8\u7f72&#xff0c;\u517c\u987e\u901f\u5ea6\u4e0e\u6548\u679c\u3002<\/p>\n<p>\u6838\u5fc3\u6d41\u7a0b&#xff1a;\u8bfb\u53d6\u56fe\u50cf\u2192\u751f\u6210\u7b26\u5408\u6a21\u578b\u8f93\u5165\u8981\u6c42\u7684Blob\u2192\u6a21\u578b\u524d\u5411\u4f20\u64ad\u2192\u7ed3\u679c\u540e\u5904\u7406&#xff08;\u7ef4\u5ea6\u8f6c\u6362\u3001\u5f52\u4e00\u5316&#xff09;\u2192\u8f93\u51fa\u98ce\u683c\u5316\u56fe\u50cf\u3002<\/p>\n<h3 id=\"2.%20%E5%AE%9E%E6%88%98%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0\">2. \u5b9e\u6218\u4ee3\u7801\u5b9e\u73b0<\/h3>\n<p>\u4f9d\u8d56\u5e93&#xff1a;&#096;opencv-python&#096;\u3001&#096;numpy&#096;&#xff0c;\u9700\u63d0\u524d\u51c6\u59074\u4e2a\u9884\u8bad\u7ec3\u6a21\u578b&#xff08;\u653e\u7f6e\u4e8e&#096;model&#096;\u6587\u4ef6\u5939&#xff09;&#xff1a;&#096;composition_vii.t7&#096;\u3001&#096;candy.t7&#096;\u3001&#096;udnie.t7&#096;\u3001&#096;feathers.t7&#096;\u3002<\/p>\n<p>import cv2<br \/>\nimport numpy as np<\/p>\n<p># 1. \u52a0\u8f7d\u9884\u8bad\u7ec3\u6a21\u578b&#xff08;\u4ec5\u52a0\u8f7d\u4e00\u6b21&#xff0c;\u63d0\u5347\u6548\u7387&#xff09;<br \/>\nmodels &#061; {<br \/>\n    &#034;left_top&#034;: cv2.dnn.readNet(&#034;model\/composition_vii.t7&#034;),<br \/>\n    &#034;right_top&#034;: cv2.dnn.readNet(&#034;model\/candy.t7&#034;),<br \/>\n    &#034;left_bottom&#034;: cv2.dnn.readNet(&#034;model\/udnie.t7&#034;),<br \/>\n    &#034;right_bottom&#034;: cv2.dnn.readNet(&#034;model\/feathers.t7&#034;)<br \/>\n}<\/p>\n<p># 2. \u98ce\u683c\u8fc1\u79fb\u6838\u5fc3\u51fd\u6570<br \/>\ndef style_transfer(img, net):<br \/>\n    h, w &#061; img.shape[:2]<br \/>\n    # \u751f\u6210\u6a21\u578b\u8f93\u5165Blob&#xff1a;\u56fe\u50cf\u5f52\u4e00\u5316\u3001\u5c3a\u5bf8\u8c03\u6574\u3001\u5747\u503c\u51cf\u6cd5<br \/>\n    blob &#061; cv2.dnn.blobFromImage(<br \/>\n        img, 1.0, (w, h), (103.939, 116.779, 123.680),<br \/>\n        swapRB&#061;True, crop&#061;False<br \/>\n    )<br \/>\n    # \u8bbe\u7f6e\u6a21\u578b\u8f93\u5165<br \/>\n    net.setInput(blob)<br \/>\n    # \u524d\u5411\u4f20\u64ad\u63a8\u7406\u98ce\u683c\u5316\u7ed3\u679c<br \/>\n    preds &#061; net.forward()<\/p>\n<p>    # \u7ed3\u679c\u540e\u5904\u7406&#xff1a;\u7ef4\u5ea6\u8f6c\u6362&#xff08;1,3,H,W&#xff09;\u2192&#xff08;H,W,3&#xff09;<br \/>\n    preds &#061; preds.reshape(3, h, w)<br \/>\n    preds &#061; np.transpose(preds, (1, 2, 0))<br \/>\n    # \u5f52\u4e00\u5316\u52300-255\u5e76\u8f6c\u4e3auint8&#xff08;OpenCV\u517c\u5bb9\u683c\u5f0f&#xff09;<br \/>\n    preds &#061; (preds &#8211; preds.min()) \/ (preds.max() &#8211; preds.min() &#043; 1e-8)<br \/>\n    preds &#061; (preds * 255).astype(np.uint8)<br \/>\n    # \u786e\u4fdd3\u901a\u9053&#xff08;\u517c\u5bb9\u7070\u5ea6\u56fe\u8f93\u5165&#xff09;<br \/>\n    if preds.shape[2] !&#061; 3:<br \/>\n        preds &#061; cv2.cvtColor(preds, cv2.COLOR_GRAY2BGR)<br \/>\n    return preds<\/p>\n<p># 3. \u6444\u50cf\u5934\u5b9e\u65f6\u98ce\u683c\u8fc1\u79fb&#xff08;\u56db\u533a\u57df\u5206\u98ce\u683c&#xff09;<br \/>\ncap &#061; cv2.VideoCapture(0)<br \/>\nwhile True:<br \/>\n    ret, frame &#061; cap.read()<br \/>\n    if not ret:<br \/>\n        break<br \/>\n    h, w &#061; frame.shape[:2]<br \/>\n    h_half, w_half &#061; h\/\/2, w\/\/2<\/p>\n<p>    # \u5206\u5272\u56fe\u50cf\u4e3a\u56db\u533a\u57df&#xff0c;\u5206\u522b\u98ce\u683c\u8fc1\u79fb<br \/>\n    tl &#061; style_transfer(frame[:h_half, :w_half], models[&#034;left_top&#034;])<br \/>\n    tr &#061; style_transfer(frame[:h_half, w_half:], models[&#034;right_top&#034;])<br \/>\n    bl &#061; style_transfer(frame[h_half:, :w_half], models[&#034;left_bottom&#034;])<br \/>\n    br &#061; style_transfer(frame[h_half:, w_half:], models[&#034;right_bottom&#034;])<\/p>\n<p>    # \u62fc\u63a5\u7ed3\u679c\u5e76\u663e\u793a<br \/>\n    top_row &#061; np.hstack((tl, tr))<br \/>\n    bottom_row &#061; np.hstack((bl, br))<br \/>\n    merged &#061; np.vstack((top_row, bottom_row))<br \/>\n    cv2.imshow(&#034;Style Transfer&#034;, merged)<\/p>\n<p>    if cv2.waitKey(1) &#061;&#061; 27:<br \/>\n        break<br \/>\ncap.release()<br \/>\ncv2.destroyAllWindows() <\/p>\n<h3 id=\"3.%20%E5%85%B3%E9%94%AE%E5%87%BD%E6%95%B0%E8%A7%A3%E6%9E%90\">3. \u5173\u952e\u51fd\u6570\u89e3\u6790<\/h3>\n<ul>\n<li>\n<p>cv2.dnn.readNet()&#xff1a;\u52a0\u8f7d\u9884\u8bad\u7ec3DNN\u6a21\u578b&#xff0c;\u652f\u6301&#096;.t7&#096;\u3001&#096;.pb&#096;\u7b49\u591a\u79cd\u683c\u5f0f&#xff0c;\u6b64\u5904\u7528\u4e8e\u8bfb\u53d6\u98ce\u683c\u8fc1\u79fb\u6a21\u578b\u3002<\/p>\n<\/li>\n<li>\n<p>cv2.dnn.blobFromImage()&#xff1a;\u5c06\u56fe\u50cf\u8f6c\u6362\u4e3a\u6a21\u578b\u53ef\u63a5\u53d7\u7684Blob\u683c\u5f0f&#xff0c;\u6838\u5fc3\u53c2\u6570\u9700\u5339\u914d\u6a21\u578b\u8bad\u7ec3\u65f6\u7684\u914d\u7f6e&#xff08;\u5747\u503c\u3001\u901a\u9053\u4ea4\u6362\u7b49&#xff09;&#xff0c;\u5426\u5219\u4f1a\u5bfc\u81f4\u98ce\u683c\u5f02\u5e38\u3002<\/p>\n<\/li>\n<li>\n<p>net.setInput()&#xff1a;\u4e3aDNN\u6a21\u578b\u8bbe\u7f6e\u8f93\u5165\u6570\u636e&#xff08;Blob\u683c\u5f0f&#xff09;&#xff0c;\u662f\u63a8\u7406\u524d\u7684\u5fc5\u8981\u6b65\u9aa4\u3002<\/p>\n<\/li>\n<li>\n<p>net.forward()&#xff1a;\u6267\u884c\u6a21\u578b\u524d\u5411\u4f20\u64ad&#xff0c;\u8fd4\u56de\u98ce\u683c\u5316\u540e\u7684\u7279\u5f81\u56fe&#xff0c;\u9700\u540e\u7eed\u7ef4\u5ea6\u8f6c\u6362\u624d\u80fd\u4f5c\u4e3a\u56fe\u50cf\u663e\u793a\u3002<\/p>\n<\/li>\n<li>\n<p>np.transpose()&#xff1a;\u8c03\u6574\u6570\u7ec4\u7ef4\u5ea6&#xff0c;\u5c06\u6a21\u578b\u8f93\u51fa\u7684&#xff08;\u901a\u9053\u6570&#xff0c;\u9ad8\u5ea6&#xff0c;\u5bbd\u5ea6&#xff09;\u8f6c\u4e3aOpenCV\u652f\u6301\u7684&#xff08;\u9ad8\u5ea6&#xff0c;\u5bbd\u5ea6&#xff0c;\u901a\u9053\u6570&#xff09;\u3002<\/p>\n<\/li>\n<\/ul>\n<h2 id=\"%E4%BA%8C%E3%80%81CSRT%E7%89%A9%E4%BD%93%E8%BF%BD%E8%B8%AA%EF%BC%9A%E5%8E%9F%E7%90%86%E4%B8%8E%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0\">\u4e8c\u3001CSRT\u7269\u4f53\u8ffd\u8e2a&#xff1a;\u539f\u7406\u4e0e\u4ee3\u7801\u5b9e\u73b0<\/h2>\n<h3 id=\"1.%20%E6%A0%B8%E5%BF%83%E5%8E%9F%E7%90%86\">1. \u6838\u5fc3\u539f\u7406<\/h3>\n<p>CSRT&#xff08;Channel and Spatial Reliability Tracking&#xff09;\u662fOpenCV\u5185\u7f6e\u7684\u9ad8\u7cbe\u5ea6\u8ffd\u8e2a\u7b97\u6cd5&#xff0c;\u7ed3\u5408\u4e86\u901a\u9053\u53ef\u9760\u6027\u548c\u7a7a\u95f4\u53ef\u9760\u6027\u8bc4\u4f30&#xff0c;\u80fd\u9002\u5e94\u5149\u7167\u53d8\u5316\u3001\u76ee\u6807\u7f29\u653e\u7b49\u573a\u666f&#xff0c;\u7cbe\u5ea6\u4f18\u4e8eKCF\u3001BOOSTING\u7b49\u7b97\u6cd5&#xff0c;\u9002\u5408\u5b9e\u65f6\u573a\u666f\u3002<\/p>\n<p>\u6838\u5fc3\u6d41\u7a0b&#xff1a;\u521d\u59cb\u5316\u8ffd\u8e2a\u5668\u2192\u624b\u52a8\u9009\u62e9ROI&#xff08;\u611f\u5174\u8da3\u533a\u57df&#xff09;\u2192\u9010\u5e27\u66f4\u65b0\u8ffd\u8e2a\u5668\u2192\u83b7\u53d6\u76ee\u6807\u5750\u6807\u5e76\u7ed8\u5236\u3002<\/p>\n<h3 id=\"2.%20%E5%AE%9E%E6%88%98%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0\">2. \u5b9e\u6218\u4ee3\u7801\u5b9e\u73b0<\/h3>\n<p>import cv2<\/p>\n<p># 1. \u521d\u59cb\u5316CSRT\u8ffd\u8e2a\u5668<br \/>\ntracker &#061; cv2.TrackerCSRT_create()<br \/>\ntracking &#061; False  # \u8ffd\u8e2a\u72b6\u6001\u6807\u5fd7<br \/>\ncap &#061; cv2.VideoCapture(0)<\/p>\n<p>while True:<br \/>\n    ret, frame &#061; cap.read()<br \/>\n    if not ret:<br \/>\n        break<\/p>\n<p>    # 2. \u6309\u952e\u63a7\u5236&#xff1a;\u6309&#039;s&#039;\u9009\u62e9ROI\u5f00\u59cb\u8ffd\u8e2a<br \/>\n    key &#061; cv2.waitKey(1) &amp; 0xFF<br \/>\n    if key &#061;&#061; ord(&#039;s&#039;):<br \/>\n        tracking &#061; True<br \/>\n        # \u9009\u62e9ROI&#xff08;\u611f\u5174\u8da3\u533a\u57df&#xff09;&#xff0c;\u8fd4\u56de&#xff08;x,y,w,h&#xff09;<br \/>\n        roi &#061; cv2.selectROI(&#034;CSRT Tracking&#034;, frame, showCrosshair&#061;False)<br \/>\n        # \u521d\u59cb\u5316\u8ffd\u8e2a\u5668&#xff08;\u7ed1\u5b9a\u5f53\u524d\u5e27\u548cROI&#xff09;<br \/>\n        tracker.init(frame, roi)<br \/>\n    elif key &#061;&#061; 27:<br \/>\n        break<\/p>\n<p>    # 3. \u8ffd\u8e2a\u66f4\u65b0<br \/>\n    if tracking:<br \/>\n        # \u9010\u5e27\u66f4\u65b0\u8ffd\u8e2a\u5668&#xff0c;\u8fd4\u56de\u8ffd\u8e2a\u72b6\u6001\u548c\u76ee\u6807\u6846\u5750\u6807<br \/>\n        success, box &#061; tracker.update(frame)<br \/>\n        if success:<br \/>\n            x, y, w, h &#061; [int(v) for v in box]<br \/>\n            # \u7ed8\u5236\u8ffd\u8e2a\u6846&#xff08;\u7eff\u8272&#xff0c;\u7ebf\u5bbd2&#xff09;<br \/>\n            cv2.rectangle(frame, (x, y), (x&#043;w, y&#043;h), (0,255,0), 2)<\/p>\n<p>    # \u663e\u793a\u7ed3\u679c<br \/>\n    cv2.imshow(&#034;CSRT Tracking&#034;, frame)<\/p>\n<p>cap.release()<br \/>\ncv2.destroyAllWindows() <\/p>\n<h3 id=\"3.%20%E5%85%B3%E9%94%AE%E5%87%BD%E6%95%B0%E8%A7%A3%E6%9E%90\">3. \u5173\u952e\u51fd\u6570\u89e3\u6790<\/h3>\n<ul>\n<li>\n<p>cv2.TrackerCSRT_create()&#xff1a;\u521b\u5efaCSRT\u8ffd\u8e2a\u5668\u5b9e\u4f8b&#xff0c;\u65e0\u9700\u989d\u5916\u914d\u7f6e&#xff0c;\u76f4\u63a5\u8c03\u7528\u5373\u53ef\u3002<\/p>\n<\/li>\n<li>\n<p>cv2.selectROI()&#xff1a;\u5f39\u51fa\u7a97\u53e3\u8ba9\u7528\u6237\u624b\u52a8\u6846\u9009\u76ee\u6807\u533a\u57df&#xff0c;\u8fd4\u56de\u77e9\u5f62\u6846\u5750\u6807&#xff08;x,y,w,h&#xff09;&#xff0c;&#096;showCrosshair&#096;\u53c2\u6570\u63a7\u5236\u662f\u5426\u663e\u793a\u5341\u5b57\u51c6\u661f\u3002<\/p>\n<\/li>\n<li>\n<p>tracker.init()&#xff1a;\u521d\u59cb\u5316\u8ffd\u8e2a\u5668&#xff0c;\u7ed1\u5b9a\u521d\u59cb\u5e27\u548cROI&#xff0c;\u662f\u8ffd\u8e2a\u7684\u8d77\u70b9&#xff0c;\u9700\u5728\u9009\u62e9ROI\u540e\u8c03\u7528\u3002<\/p>\n<\/li>\n<li>\n<p>tracker.update()&#xff1a;\u9010\u5e27\u66f4\u65b0\u8ffd\u8e2a\u72b6\u6001&#xff0c;\u8fd4\u56de\u4e24\u4e2a\u503c&#xff1a;&#096;success&#096;&#xff08;\u5e03\u5c14\u503c&#xff0c;\u8ffd\u8e2a\u662f\u5426\u6210\u529f&#xff09;\u548c&#096;box&#096;&#xff08;\u76ee\u6807\u6846\u5750\u6807&#xff09;&#xff0c;\u5931\u8d25\u65f6&#096;box&#096;\u65e0\u6548\u3002<\/p>\n<\/li>\n<li>\n<p>cv2.rectangle()&#xff1a;\u5728\u56fe\u50cf\u4e0a\u7ed8\u5236\u77e9\u5f62\u8ffd\u8e2a\u6846&#xff0c;\u53c2\u6570\u4f9d\u6b21\u4e3a&#xff1a;\u56fe\u50cf\u3001\u5de6\u4e0a\u89d2\u5750\u6807\u3001\u53f3\u4e0b\u89d2\u5750\u6807\u3001\u989c\u8272\u3001\u7ebf\u5bbd\u3002<\/p>\n<\/li>\n<\/ul>\n<h2 id=\"%E4%B8%89%E3%80%81%E4%B8%A4%E8%80%85%E6%95%B4%E5%90%88%EF%BC%9A%E5%AE%9E%E6%97%B6%E9%A3%8E%E6%A0%BC%E8%BF%81%E7%A7%BB%2B%E7%89%A9%E4%BD%93%E8%BF%BD%E8%B8%AA\">\u4e09\u3001\u4e24\u8005\u6574\u5408&#xff1a;\u5b9e\u65f6\u98ce\u683c\u8fc1\u79fb&#043;\u7269\u4f53\u8ffd\u8e2a<\/h2>\n<h3 id=\"1.%20%E6%95%B4%E5%90%88%E6%A0%B8%E5%BF%83%E9%80%BB%E8%BE%91\">1. \u6574\u5408\u6838\u5fc3\u903b\u8f91<\/h3>\n<p>\u6574\u5408\u7684\u5173\u952e\u662f\u89e3\u51b3\u4e24\u4e2a\u6838\u5fc3\u95ee\u9898&#xff1a;\u2460 \u8ffd\u8e2a\u7cbe\u5ea6&#xff1a;\u98ce\u683c\u8fc1\u79fb\u4f1a\u6539\u53d8\u56fe\u50cf\u50cf\u7d20&#xff0c;\u76f4\u63a5\u5728\u98ce\u683c\u5316\u56fe\u50cf\u4e0a\u8ffd\u8e2a\u4f1a\u5bfc\u81f4\u7cbe\u5ea6\u4e0b\u964d&#xff0c;\u56e0\u6b64\u91c7\u7528\u201c\u539f\u59cb\u5e27\u8ffd\u8e2a\u2192\u98ce\u683c\u5316\u5904\u7406\u2192\u8ffd\u8e2a\u6846\u7ed8\u5236\u5230\u98ce\u683c\u5316\u56fe\u50cf\u201d\u7684\u6d41\u7a0b&#xff1b;\u2461 \u683c\u5f0f\u517c\u5bb9&#xff1a;\u98ce\u683c\u5316\u7ed3\u679c\u9700\u8f6c\u4e3aOpenCV\u517c\u5bb9\u683c\u5f0f&#xff08;3\u901a\u9053\u3001uint8\u3001\u8fde\u7eed\u5185\u5b58\u5e03\u5c40&#xff09;&#xff0c;\u907f\u514d\u7ed8\u56fe\u62a5\u9519\u3002<\/p>\n<h3 id=\"2.%20%E6%95%B4%E5%90%88%E5%90%8E%E5%AE%8C%E6%95%B4%E4%BB%A3%E7%A0%81\">2. \u6574\u5408\u540e\u5b8c\u6574\u4ee3\u7801<\/h3>\n<p>import cv2<br \/>\nimport numpy as np<\/p>\n<p># &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061; \u521d\u59cb\u5316\u914d\u7f6e &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<br \/>\ncap &#061; cv2.VideoCapture(0)<br \/>\nif not cap.isOpened():<br \/>\n    print(&#034;\u65e0\u6cd5\u6253\u5f00\u6444\u50cf\u5934&#xff01;&#034;)<br \/>\n    exit()<\/p>\n<p># \u521d\u59cb\u5316CSRT\u8ffd\u8e2a\u5668<br \/>\ntracker &#061; cv2.TrackerCSRT_create()<br \/>\ntracking &#061; False<br \/>\ntrack_box &#061; None<\/p>\n<p># \u52a0\u8f7d\u98ce\u683c\u8fc1\u79fb\u6a21\u578b<br \/>\ntry:<br \/>\n    models &#061; {<br \/>\n        &#034;left_top&#034;: cv2.dnn.readNet(&#034;model\/composition_vii.t7&#034;),<br \/>\n        &#034;right_top&#034;: cv2.dnn.readNet(&#034;model\/candy.t7&#034;),<br \/>\n        &#034;left_bottom&#034;: cv2.dnn.readNet(&#034;model\/udnie.t7&#034;),<br \/>\n        &#034;right_bottom&#034;: cv2.dnn.readNet(&#034;model\/feathers.t7&#034;)<br \/>\n    }<br \/>\n    print(&#034;\u6a21\u578b\u52a0\u8f7d\u6210\u529f&#xff01;&#034;)<br \/>\nexcept Exception as e:<br \/>\n    print(f&#034;\u6a21\u578b\u52a0\u8f7d\u5931\u8d25&#xff1a;{e}&#034;)<br \/>\n    cap.release()<br \/>\n    exit()<\/p>\n<p># &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061; \u6838\u5fc3\u51fd\u6570 &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<br \/>\ndef style_transfer(img, net):<br \/>\n    h, w &#061; img.shape[:2]<br \/>\n    blob &#061; cv2.dnn.blobFromImage(<br \/>\n        img, 1.0, (w, h), (103.939, 116.779, 123.680),<br \/>\n        swapRB&#061;True, crop&#061;False<br \/>\n    )<br \/>\n    net.setInput(blob)<br \/>\n    preds &#061; net.forward()<br \/>\n    preds &#061; preds.reshape(3, h, w)<br \/>\n    preds &#061; np.transpose(preds, (1, 2, 0))<br \/>\n    preds &#061; (preds &#8211; preds.min()) \/ (preds.max() &#8211; preds.min() &#043; 1e-8)<br \/>\n    preds &#061; (preds * 255).astype(np.uint8)<br \/>\n    if preds.shape[2] !&#061; 3:<br \/>\n        preds &#061; cv2.cvtColor(preds, cv2.COLOR_GRAY2BGR)<br \/>\n    return preds<\/p>\n<p># &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061; \u4e3b\u5faa\u73af &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<br \/>\nwhile True:<br \/>\n    ret, frame &#061; cap.read()<br \/>\n    if not ret:<br \/>\n        break<br \/>\n    frame_h, frame_w &#061; frame.shape[:2]<br \/>\n    if len(frame.shape) &#061;&#061; 2:<br \/>\n        frame &#061; cv2.cvtColor(frame, cv2.COLOR_GRAY2BGR)<\/p>\n<p>    # \u6309\u952e\u63a7\u5236<br \/>\n    key &#061; cv2.waitKey(1) &amp; 0xFF<br \/>\n    if key &#061;&#061; ord(&#039;s&#039;):<br \/>\n        tracking &#061; True<br \/>\n        roi &#061; cv2.selectROI(&#034;Tracking &#043; Style Transfer&#034;, frame, showCrosshair&#061;False)<br \/>\n        tracker.init(frame, roi)<br \/>\n    elif key &#061;&#061; 27:<br \/>\n        break<\/p>\n<p>    # \u539f\u59cb\u5e27\u4e0a\u66f4\u65b0\u8ffd\u8e2a<br \/>\n    if tracking:<br \/>\n        success, box &#061; tracker.update(frame)<br \/>\n        track_box &#061; [int(v) for v in box] if success else None<\/p>\n<p>    # \u56db\u533a\u57df\u98ce\u683c\u8fc1\u79fb<br \/>\n    h_half, w_half &#061; frame_h\/\/2, frame_w\/\/2<br \/>\n    tl &#061; style_transfer(frame[:h_half, :w_half], models[&#034;left_top&#034;])<br \/>\n    tr &#061; style_transfer(frame[:h_half, w_half:], models[&#034;right_top&#034;])<br \/>\n    bl &#061; style_transfer(frame[h_half:, :w_half], models[&#034;left_bottom&#034;])<br \/>\n    br &#061; style_transfer(frame[h_half:, w_half:], models[&#034;right_bottom&#034;])<\/p>\n<p>    # \u62fc\u63a5\u98ce\u683c\u5316\u56fe\u50cf&#xff08;\u7edf\u4e00\u5c3a\u5bf8&#043;\u8fde\u7eed\u5185\u5b58\u5e03\u5c40&#xff09;<br \/>\n    tl &#061; cv2.resize(tl, (w_half, h_half))<br \/>\n    tr &#061; cv2.resize(tr, (w_half, h_half))<br \/>\n    bl &#061; cv2.resize(bl, (w_half, h_half))<br \/>\n    br &#061; cv2.resize(br, (w_half, h_half))<br \/>\n    top_row &#061; np.hstack((tl, tr))<br \/>\n    bottom_row &#061; np.hstack((bl, br))<br \/>\n    styled_frame &#061; np.vstack((top_row, bottom_row))<br \/>\n    # \u5173\u952e&#xff1a;\u8f6c\u4e3a\u8fde\u7eed\u5185\u5b58\u5e03\u5c40&#xff0c;\u89e3\u51b3OpenCV\u7ed8\u56fe\u517c\u5bb9\u95ee\u9898<br \/>\n    styled_frame &#061; np.ascontiguousarray(styled_frame, dtype&#061;np.uint8)<\/p>\n<p>    # \u7ed8\u5236\u8ffd\u8e2a\u6846<br \/>\n    if tracking and track_box is not None:<br \/>\n        x, y, w, h &#061; track_box<br \/>\n        if 0 &lt;&#061; x &lt; frame_w and 0 &lt;&#061; y &lt; frame_h:<br \/>\n            cv2.rectangle(styled_frame, (x, y), (x&#043;w, y&#043;h), (0,255,0), 2)<\/p>\n<p>    cv2.imshow(&#034;Tracking &#043; Style Transfer&#034;, styled_frame)<\/p>\n<p>cap.release()<br \/>\ncv2.destroyAllWindows() <\/p>\n<h3 id=\"3.%20%E6%95%B4%E5%90%88%E5%85%B3%E9%94%AE%E4%BC%98%E5%8C%96%E7%82%B9\">3. \u6574\u5408\u5173\u952e\u4f18\u5316\u70b9<\/h3>\n<ul>\n<li>\n<p>\u8ffd\u8e2a\u4e0e\u98ce\u683c\u5316\u987a\u5e8f&#xff1a;\u4f18\u5148\u5728\u539f\u59cb\u5e27\u4e0a\u6267\u884ctracker.update()&#xff0c;\u786e\u4fdd\u8ffd\u8e2a\u7cbe\u5ea6&#xff0c;\u518d\u5bf9\u539f\u59cb\u5e27\u505a\u98ce\u683c\u8fc1\u79fb&#xff0c;\u6700\u540e\u5c06\u8ffd\u8e2a\u6846\u7ed8\u5236\u5230\u98ce\u683c\u5316\u56fe\u50cf\u4e0a&#xff0c;\u907f\u514d\u98ce\u683c\u5316\u5e72\u6270\u8ffd\u8e2a\u3002<\/p>\n<\/li>\n<li>\n<p>\u683c\u5f0f\u517c\u5bb9\u6027\u4fee\u590d&#xff1a;\u901a\u8fc7np.ascontiguousarray()\u5f3a\u5236\u98ce\u683c\u5316\u56fe\u50cf\u4e3a\u8fde\u7eed\u5185\u5b58\u5e03\u5c40&#xff0c;\u89e3\u51b3OpenCV cv2.rectangle() \u51fd\u6570\u62a5\u201cLayout incompatible\u201d\u9519\u8bef\u7684\u95ee\u9898\u3002<\/p>\n<\/li>\n<li>\n<p>\u5c3a\u5bf8\u7edf\u4e00&#xff1a;\u7528cv2.resize() \u7edf\u4e00\u56db\u533a\u57df\u98ce\u683c\u5316\u7ed3\u679c\u7684\u5c3a\u5bf8&#xff0c;\u907f\u514d\u62fc\u63a5\u540e\u56fe\u50cf\u53d8\u5f62&#xff0c;\u786e\u4fdd\u8ffd\u8e2a\u6846\u5750\u6807\u6620\u5c04\u51c6\u786e\u3002<\/p>\n<\/li>\n<li>\n<p>\u9c81\u68d2\u6027\u589e\u5f3a&#xff1a;\u589e\u52a0\u6444\u50cf\u5934\u6253\u5f00\u6821\u9a8c\u3001\u6a21\u578b\u52a0\u8f7d\u5f02\u5e38\u5904\u7406\u3001\u5750\u6807\u8d8a\u754c\u5224\u65ad&#xff0c;\u907f\u514d\u7a0b\u5e8f\u76f4\u63a5\u5d29\u6e83\u3002<\/p>\n<\/li>\n<\/ul>\n<h2 id=\"%E5%9B%9B%E3%80%81%E5%AE%9E%E6%88%98%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9\">\u56db\u3001\u5b9e\u6218\u6ce8\u610f\u4e8b\u9879<\/h2>\n<li>\n<p>\u6a21\u578b\u8def\u5f84&#xff1a;\u786e\u4fdd&#096;model&#096;\u6587\u4ef6\u5939\u4e0e\u4ee3\u7801\u6587\u4ef6\u540c\u7ea7&#xff0c;\u6a21\u578b\u6587\u4ef6\u540d\u4e0e\u4ee3\u7801\u4e2d\u4e00\u81f4&#xff0c;\u5426\u5219\u4f1a\u62a5\u6a21\u578b\u52a0\u8f7d\u5931\u8d25\u9519\u8bef\u3002<\/p>\n<\/li>\n<li>\n<p>\u6027\u80fd\u4f18\u5316&#xff1a;\u82e5\u8fd0\u884c\u5361\u987f&#xff0c;\u53ef\u7f29\u5c0f\u6444\u50cf\u5934\u5206\u8fa8\u7387&#xff08;\u5982&#096;cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)&#096;&#xff09;&#xff0c;\u51cf\u5c11\u98ce\u683c\u8fc1\u79fb\u7684\u8ba1\u7b97\u91cf\u3002<\/p>\n<\/li>\n<li>\n<p>\u8ffd\u8e2a\u7a33\u5b9a\u6027&#xff1a;CSRT\u7cbe\u5ea6\u9ad8\u4f46\u901f\u5ea6\u7565\u6162&#xff0c;\u82e5\u9700\u5b9e\u65f6\u6027\u4f18\u5148&#xff0c;\u53ef\u66ff\u6362\u4e3acv2.TrackerKCF_create() \u8ffd\u8e2a\u5668\u3002<\/p>\n<\/li>\n<li>\n<p>\u98ce\u683c\u8c03\u6574&#xff1a;\u66f4\u6362&#096;.t7&#096;\u6a21\u578b\u5373\u53ef\u5207\u6362\u98ce\u683c&#xff0c;\u53ef\u4eceOpenCV\u5b98\u65b9\u4ed3\u5e93\u6216\u7b2c\u4e09\u65b9\u8d44\u6e90\u83b7\u53d6\u66f4\u591a\u9884\u8bad\u7ec3\u6a21\u578b\u3002<\/p>\n<\/li>\n<p>\u672c\u6587\u901a\u8fc7\u6a21\u5757\u5316\u62c6\u89e3\u4e0e\u6574\u5408&#xff0c;\u5b9e\u73b0\u4e86\u4e24\u79cd\u6838\u5fc3\u89c6\u89c9\u4efb\u52a1\u7684\u878d\u5408&#xff0c;\u4ee3\u7801\u53ef\u76f4\u63a5\u843d\u5730\u8fd0\u884c\u3002\u5b9e\u9645\u9879\u76ee\u4e2d\u53ef\u57fa\u4e8e\u6b64\u6269\u5c55&#xff0c;\u5982\u589e\u52a0\u591a\u76ee\u6807\u8ffd\u8e2a\u3001\u98ce\u683c\u5207\u6362\u6309\u952e\u3001\u89c6\u9891\u6587\u4ef6\u8f93\u5165\u8f93\u51fa\u7b49\u529f\u80fd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u5f55<br \/>\n\u4e00\u3001DNN\u98ce\u683c\u8fc1\u79fb&#xff1a;\u539f\u7406\u4e0e\u4ee3\u7801\u5b9e\u73b0<br \/>\n1. \u6838\u5fc3\u539f\u7406<br \/>\n2. \u5b9e\u6218\u4ee3\u7801\u5b9e\u73b0<br \/>\n3. \u5173\u952e\u51fd\u6570\u89e3\u6790<br \/>\n\u4e8c\u3001CSRT\u7269\u4f53\u8ffd\u8e2a&#xff1a;\u539f\u7406\u4e0e\u4ee3\u7801\u5b9e\u73b0<br \/>\n1. \u6838\u5fc3\u539f\u7406<br \/>\n2. \u5b9e\u6218\u4ee3\u7801\u5b9e\u73b0<br \/>\n3. \u5173\u952e\u51fd\u6570\u89e3\u6790<br \/>\n\u4e09\u3001\u4e24\u8005\u6574\u5408&#xff1a;\u5b9e\u65f6\u98ce\u683c\u8fc1\u79fb\u7269\u4f53\u8ffd\u8e2a<br \/>\n1. \u6574\u5408\u6838\u5fc3\u903b\u8f91<br \/>\n2. \u6574\u5408\u540e\u5b8c\u6574\u4ee3\u7801<br \/>\n3. \u6574\u5408\u5173\u952e\u4f18\u5316\u70b9<br \/>\n\u56db\u3001\u5b9e\u6218\u6ce8\u610f\u4e8b\u9879 \u5728\u8ba1\u7b97\u673a\u89c6\u89c9\u5b9e\u6218\u4e2d&#xff0c;\u5c06\u98ce\u683c\u8fc1\u79fb\u4e0e\u7269\u4f53\u8ffd\u8e2a\u7ed3\u5408\u53ef\u5b9e\u73b0\u66f4\u5177\u89c6\u89c9\u51b2\u51fb\u529b\u7684\u6548\u679c\u3002\u672c\u6587\u57fa\u4e8eOpen<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[6342,1460,50],"topic":[],"class_list":["post-66998","post","type-post","status-publish","format-standard","hentry","category-server","tag-dnn","tag-opencv","tag-50"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>OpenCV\u5b9e\u6218\uff1aDNN\u98ce\u683c\u8fc1\u79fb\u4e0eCSRT\u7269\u4f53\u8ffd\u8e2a - \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\/66998.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"OpenCV\u5b9e\u6218\uff1aDNN\u98ce\u683c\u8fc1\u79fb\u4e0eCSRT\u7269\u4f53\u8ffd\u8e2a - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u76ee\u5f55 \u4e00\u3001DNN\u98ce\u683c\u8fc1\u79fb&#xff1a;\u539f\u7406\u4e0e\u4ee3\u7801\u5b9e\u73b0 1. \u6838\u5fc3\u539f\u7406 2. \u5b9e\u6218\u4ee3\u7801\u5b9e\u73b0 3. \u5173\u952e\u51fd\u6570\u89e3\u6790 \u4e8c\u3001CSRT\u7269\u4f53\u8ffd\u8e2a&#xff1a;\u539f\u7406\u4e0e\u4ee3\u7801\u5b9e\u73b0 1. \u6838\u5fc3\u539f\u7406 2. \u5b9e\u6218\u4ee3\u7801\u5b9e\u73b0 3. \u5173\u952e\u51fd\u6570\u89e3\u6790 \u4e09\u3001\u4e24\u8005\u6574\u5408&#xff1a;\u5b9e\u65f6\u98ce\u683c\u8fc1\u79fb\u7269\u4f53\u8ffd\u8e2a 1. \u6574\u5408\u6838\u5fc3\u903b\u8f91 2. \u6574\u5408\u540e\u5b8c\u6574\u4ee3\u7801 3. \u6574\u5408\u5173\u952e\u4f18\u5316\u70b9 \u56db\u3001\u5b9e\u6218\u6ce8\u610f\u4e8b\u9879 \u5728\u8ba1\u7b97\u673a\u89c6\u89c9\u5b9e\u6218\u4e2d&#xff0c;\u5c06\u98ce\u683c\u8fc1\u79fb\u4e0e\u7269\u4f53\u8ffd\u8e2a\u7ed3\u5408\u53ef\u5b9e\u73b0\u66f4\u5177\u89c6\u89c9\u51b2\u51fb\u529b\u7684\u6548\u679c\u3002\u672c\u6587\u57fa\u4e8eOpen\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/66998.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-27T16:04:45+00:00\" \/>\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=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/66998.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/66998.html\",\"name\":\"OpenCV\u5b9e\u6218\uff1aDNN\u98ce\u683c\u8fc1\u79fb\u4e0eCSRT\u7269\u4f53\u8ffd\u8e2a - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-27T16:04:45+00:00\",\"dateModified\":\"2026-01-27T16:04:45+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/66998.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/66998.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/66998.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"OpenCV\u5b9e\u6218\uff1aDNN\u98ce\u683c\u8fc1\u79fb\u4e0eCSRT\u7269\u4f53\u8ffd\u8e2a\"}]},{\"@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\u5b9e\u6218\uff1aDNN\u98ce\u683c\u8fc1\u79fb\u4e0eCSRT\u7269\u4f53\u8ffd\u8e2a - \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\/66998.html","og_locale":"zh_CN","og_type":"article","og_title":"OpenCV\u5b9e\u6218\uff1aDNN\u98ce\u683c\u8fc1\u79fb\u4e0eCSRT\u7269\u4f53\u8ffd\u8e2a - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u76ee\u5f55 \u4e00\u3001DNN\u98ce\u683c\u8fc1\u79fb&#xff1a;\u539f\u7406\u4e0e\u4ee3\u7801\u5b9e\u73b0 1. \u6838\u5fc3\u539f\u7406 2. \u5b9e\u6218\u4ee3\u7801\u5b9e\u73b0 3. \u5173\u952e\u51fd\u6570\u89e3\u6790 \u4e8c\u3001CSRT\u7269\u4f53\u8ffd\u8e2a&#xff1a;\u539f\u7406\u4e0e\u4ee3\u7801\u5b9e\u73b0 1. \u6838\u5fc3\u539f\u7406 2. \u5b9e\u6218\u4ee3\u7801\u5b9e\u73b0 3. \u5173\u952e\u51fd\u6570\u89e3\u6790 \u4e09\u3001\u4e24\u8005\u6574\u5408&#xff1a;\u5b9e\u65f6\u98ce\u683c\u8fc1\u79fb\u7269\u4f53\u8ffd\u8e2a 1. \u6574\u5408\u6838\u5fc3\u903b\u8f91 2. \u6574\u5408\u540e\u5b8c\u6574\u4ee3\u7801 3. \u6574\u5408\u5173\u952e\u4f18\u5316\u70b9 \u56db\u3001\u5b9e\u6218\u6ce8\u610f\u4e8b\u9879 \u5728\u8ba1\u7b97\u673a\u89c6\u89c9\u5b9e\u6218\u4e2d&#xff0c;\u5c06\u98ce\u683c\u8fc1\u79fb\u4e0e\u7269\u4f53\u8ffd\u8e2a\u7ed3\u5408\u53ef\u5b9e\u73b0\u66f4\u5177\u89c6\u89c9\u51b2\u51fb\u529b\u7684\u6548\u679c\u3002\u672c\u6587\u57fa\u4e8eOpen","og_url":"https:\/\/www.wsisp.com\/helps\/66998.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-27T16:04:45+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/66998.html","url":"https:\/\/www.wsisp.com\/helps\/66998.html","name":"OpenCV\u5b9e\u6218\uff1aDNN\u98ce\u683c\u8fc1\u79fb\u4e0eCSRT\u7269\u4f53\u8ffd\u8e2a - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-27T16:04:45+00:00","dateModified":"2026-01-27T16:04:45+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/66998.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/66998.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/66998.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"OpenCV\u5b9e\u6218\uff1aDNN\u98ce\u683c\u8fc1\u79fb\u4e0eCSRT\u7269\u4f53\u8ffd\u8e2a"}]},{"@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\/66998","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=66998"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/66998\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=66998"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=66998"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=66998"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=66998"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}