{"id":375,"date":"2023-05-11T20:06:47","date_gmt":"2023-05-11T12:06:47","guid":{"rendered":"https:\/\/yhsbj.cn\/?p=375"},"modified":"2023-05-11T20:06:47","modified_gmt":"2023-05-11T12:06:47","slug":"python-opencv-%e4%bb%bf%e5%b0%84%e5%8f%98%e6%8d%a2%e3%80%81%e5%b9%b3%e7%a7%bb%e3%80%81%e6%97%8b%e8%bd%ac%e3%80%81%e7%bc%a9%e6%94%be%e3%80%81%e9%80%8f%e8%a7%86%e5%8f%98%e6%8d%a2","status":"publish","type":"post","link":"https:\/\/yhsbj.cn\/index.php\/2023\/05\/11\/375\/","title":{"rendered":"Python OpenCv \u4eff\u5c04\u53d8\u6362\u3001\u5e73\u79fb\u3001\u65cb\u8f6c\u3001\u7f29\u653e\u3001\u900f\u89c6\u53d8\u6362"},"content":{"rendered":"\n<p>\u4eff\u5c04\u53d8\u6362<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import cv2\nimport numpy\n\nimg = cv2.imread(\"D:\/test123.png\")\nrows, cols = img.shape[:2]\np1 = numpy.float32([[0, 0], [cols - 1, 0], [0, rows - 1]])\np2 = numpy.float32([[0, rows * 0.3], [cols * 0.8, rows * 0.5], [cols * 0.2, rows * 0.7]])\n\nM = cv2.getAffineTransform(p1, p2)\nres = cv2.warpAffine(img, M, (cols, rows))\n\ncv2.imshow(\"\u6d4b\u8bd51\", img)\ncv2.imshow(\"\u6d4b\u8bd52\", res)\n\ncv2.waitKey()\ncv2.destroyAllWindows()<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" src=\"https:\/\/yhsbj.cn\/wp-content\/uploads\/2023\/05\/\u5c4f\u5e55\u622a\u56fe-2023-05-11-195356.png\" alt=\"\" class=\"wp-image-376\" width=\"426\" height=\"295\" srcset=\"https:\/\/yhsbj.cn\/wp-content\/uploads\/2023\/05\/\u5c4f\u5e55\u622a\u56fe-2023-05-11-195356.png 1018w, https:\/\/yhsbj.cn\/wp-content\/uploads\/2023\/05\/\u5c4f\u5e55\u622a\u56fe-2023-05-11-195356-300x208.png 300w, https:\/\/yhsbj.cn\/wp-content\/uploads\/2023\/05\/\u5c4f\u5e55\u622a\u56fe-2023-05-11-195356-768x533.png 768w\" sizes=\"(max-width: 426px) 100vw, 426px\" \/><\/figure>\n\n\n\n<p>\u5e73\u79fb<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import cv2\nimport numpy\n\nimg = cv2.imread(\"D:\/test11.png\")\nrows, cols = img.shape[:2]\np1 = numpy.float32([[0, 0], [cols - 1, 0], [0, rows - 1]])\np2 = numpy.float32([[25, 40], [cols - 1 + 25, 40], [25, rows - 1 + 40]])\n\nM = cv2.getAffineTransform(p1, p2)\nres = cv2.warpAffine(img, M, (cols, rows))\n\ncv2.imshow(\"\u6d4b\u8bd51\", img)\ncv2.imshow(\"\u6d4b\u8bd52\", res)\n\ncv2.waitKey()\ncv2.destroyAllWindows()<\/pre>\n\n\n\n<p>\u5e73\u79fb\u5feb\u6377\u65b9\u5f0f<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import cv2\nimport numpy\n\nimg = cv2.imread(\"D:\/test11.png\")\nrows, cols = img.shape[:2]\nM = numpy.float32([[1, 0, 25], [0, 1, 40]])\nres = cv2.warpAffine(img, M, (cols, rows))\n\ncv2.imshow(\"\u6d4b\u8bd51\", img)\ncv2.imshow(\"\u6d4b\u8bd52\", res)\n\ncv2.waitKey()\ncv2.destroyAllWindows()<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" src=\"https:\/\/yhsbj.cn\/wp-content\/uploads\/2023\/05\/\u5c4f\u5e55\u622a\u56fe-2023-05-11-195710.png\" alt=\"\" class=\"wp-image-377\" width=\"423\" height=\"292\" srcset=\"https:\/\/yhsbj.cn\/wp-content\/uploads\/2023\/05\/\u5c4f\u5e55\u622a\u56fe-2023-05-11-195710.png 993w, https:\/\/yhsbj.cn\/wp-content\/uploads\/2023\/05\/\u5c4f\u5e55\u622a\u56fe-2023-05-11-195710-300x207.png 300w, https:\/\/yhsbj.cn\/wp-content\/uploads\/2023\/05\/\u5c4f\u5e55\u622a\u56fe-2023-05-11-195710-768x531.png 768w\" sizes=\"(max-width: 423px) 100vw, 423px\" \/><\/figure>\n\n\n\n<p>\u65cb\u8f6c<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import cv2\nimport numpy\n\nimg = cv2.imread(\"D:\/test11.png\")\nrows, cols = img.shape[:2]\np1 = numpy.float32([[0, 0], [cols - 1, 0], [0, rows - 1]])\np2 = numpy.float32([[25, 40], [cols - 1 + 25, 40], [25, rows - 1 + 40]])\n\nM = cv2.getRotationMatrix2D((cols \/ 2, rows \/ 2), 45, 1)#\u4e2d\u5fc3\u70b9, 45\u00b0\u89d2, \u7f29\u653e\u6bd4\u4f8b1\nres = cv2.warpAffine(img, M, (cols, rows))\n\ncv2.imshow(\"\u6d4b\u8bd51\", img)\ncv2.imshow(\"\u6d4b\u8bd52\", res)\n\ncv2.waitKey()\ncv2.destroyAllWindows()<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" src=\"https:\/\/yhsbj.cn\/wp-content\/uploads\/2023\/05\/\u5c4f\u5e55\u622a\u56fe-2023-05-11-200200.png\" alt=\"\" class=\"wp-image-378\" width=\"440\" height=\"306\" srcset=\"https:\/\/yhsbj.cn\/wp-content\/uploads\/2023\/05\/\u5c4f\u5e55\u622a\u56fe-2023-05-11-200200.png 994w, https:\/\/yhsbj.cn\/wp-content\/uploads\/2023\/05\/\u5c4f\u5e55\u622a\u56fe-2023-05-11-200200-300x208.png 300w, https:\/\/yhsbj.cn\/wp-content\/uploads\/2023\/05\/\u5c4f\u5e55\u622a\u56fe-2023-05-11-200200-768x533.png 768w\" sizes=\"(max-width: 440px) 100vw, 440px\" \/><\/figure>\n\n\n\n<p>\u7f29\u653e<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import cv2\n\nimg = cv2.imread(\"D:\/test11.png\")\nres = cv2.resize(img, (300, 200))\n\ncv2.imshow(\"\u6d4b\u8bd51\", img)\ncv2.imshow(\"\u6d4b\u8bd52\", res)\n\ncv2.waitKey()\ncv2.destroyAllWindows()<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" src=\"https:\/\/yhsbj.cn\/wp-content\/uploads\/2023\/05\/\u5c4f\u5e55\u622a\u56fe-2023-05-11-200321.png\" alt=\"\" class=\"wp-image-379\" width=\"315\" height=\"270\" srcset=\"https:\/\/yhsbj.cn\/wp-content\/uploads\/2023\/05\/\u5c4f\u5e55\u622a\u56fe-2023-05-11-200321.png 843w, https:\/\/yhsbj.cn\/wp-content\/uploads\/2023\/05\/\u5c4f\u5e55\u622a\u56fe-2023-05-11-200321-300x257.png 300w, https:\/\/yhsbj.cn\/wp-content\/uploads\/2023\/05\/\u5c4f\u5e55\u622a\u56fe-2023-05-11-200321-768x659.png 768w\" sizes=\"(max-width: 315px) 100vw, 315px\" \/><\/figure>\n\n\n\n<p>\u900f\u89c6\u53d8\u6362<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import cv2\nimport numpy\n\nimg = cv2.imread(\"D:\/test11.png\")\nrows, cols = img.shape[:2]\np1 = numpy.float32([[0, 0], [cols - 1, 0], [0, rows - 1], [cols - 1, rows - 1]])\np2 = numpy.float32([[0, rows * 0.3], [cols * 0.8, rows * 0.5], [cols * 0.2, rows * 0.7], [cols * 0.8, rows * 0.8]])\n\nM = cv2.getPerspectiveTransform(p1, p2)\nres = cv2.warpPerspective(img, M, (cols, rows))\n\ncv2.imshow(\"\u6d4b\u8bd51\", img)\ncv2.imshow(\"\u6d4b\u8bd52\", res)\n\ncv2.waitKey()\ncv2.destroyAllWindows()<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" src=\"https:\/\/yhsbj.cn\/wp-content\/uploads\/2023\/05\/\u5c4f\u5e55\u622a\u56fe-2023-05-11-200546.png\" alt=\"\" class=\"wp-image-380\" width=\"437\" height=\"301\" srcset=\"https:\/\/yhsbj.cn\/wp-content\/uploads\/2023\/05\/\u5c4f\u5e55\u622a\u56fe-2023-05-11-200546.png 988w, https:\/\/yhsbj.cn\/wp-content\/uploads\/2023\/05\/\u5c4f\u5e55\u622a\u56fe-2023-05-11-200546-300x207.png 300w, https:\/\/yhsbj.cn\/wp-content\/uploads\/2023\/05\/\u5c4f\u5e55\u622a\u56fe-2023-05-11-200546-768x530.png 768w\" sizes=\"(max-width: 437px) 100vw, 437px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u4eff\u5c04\u53d8\u6362 \u5e73\u79fb \u5e73\u79fb\u5feb\u6377\u65b9\u5f0f \u65cb\u8f6c \u7f29\u653e \u900f\u89c6\u53d8\u6362<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[43,29],"tags":[44,30],"_links":{"self":[{"href":"https:\/\/yhsbj.cn\/index.php\/wp-json\/wp\/v2\/posts\/375"}],"collection":[{"href":"https:\/\/yhsbj.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yhsbj.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yhsbj.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yhsbj.cn\/index.php\/wp-json\/wp\/v2\/comments?post=375"}],"version-history":[{"count":1,"href":"https:\/\/yhsbj.cn\/index.php\/wp-json\/wp\/v2\/posts\/375\/revisions"}],"predecessor-version":[{"id":381,"href":"https:\/\/yhsbj.cn\/index.php\/wp-json\/wp\/v2\/posts\/375\/revisions\/381"}],"wp:attachment":[{"href":"https:\/\/yhsbj.cn\/index.php\/wp-json\/wp\/v2\/media?parent=375"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yhsbj.cn\/index.php\/wp-json\/wp\/v2\/categories?post=375"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yhsbj.cn\/index.php\/wp-json\/wp\/v2\/tags?post=375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}