{"id":63474,"date":"2021-04-20T13:41:56","date_gmt":"2021-04-20T05:41:56","guid":{"rendered":"http:\/\/www.zhushiyao.com\/?p=63474"},"modified":"2021-04-20T13:42:45","modified_gmt":"2021-04-20T05:42:45","slug":"d15c485a40","status":"publish","type":"post","link":"http:\/\/www.zhushiyao.com\/?p=63474","title":{"rendered":"\u7528\u4e0d\u523020\u884c\u4ee3\u7801\u5236\u4f5c\u4e00\u4e2a \u201c\u624b\u7ed8\u98ce\u201d \u89c6\u9891"},"content":{"rendered":"<div class=\"bpp-post-content\">\n<section style=\"font-size: 16px; color: black; line-height: 1.6; letter-spacing: 0px; word-break: break-word; overflow-wrap: break-word; text-align: left; font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, 'PingFang SC', Cambria, Cochin, Georgia, Times, 'Times New Roman', serif; padding: 5px;\"><hr style=\"border-style: solid; border-width: 1px 0 0; border-color: rgba(0,0,0,0.1); -webkit-transform-origin: 0 0; -webkit-transform: scale(1, 0.5); transform-origin: 0 0; transform: scale(1, 0.5);\" \/>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\">\u4eca\u5929\u5206\u4eab\u7684\u6587\u7ae0\u4e0e\u8ba1\u7b97\u673a\u89c6\u89c9\u76f8\u5173\uff0c\u7528\u4e0d\u5230 20 \u884cPython\u4ee3\u7801\u5c06\u4e00\u5f20\u5b9e\u62cd\u56fe\u7247\u8f6c\u5316\u4e3a<strong style=\"color: #108ee9;\">\u624b\u7ed8\u98ce<\/strong>\uff0c\u65e0\u9700\u5bf9\u56fe\u7247\u8fdb\u884c\u4efb\u4f55\u9884\u5904\u7406\u3001\u540e\u5904\u7406\uff1b\u4ee3\u7801\u4e2d\u53ea\u501f\u52a9\u4e86\u4e24\u4e2a\u5e38\u89c1\u5e93\uff0c\u6838\u5fc3\u8ba1\u7b97\u7531 \u00a0Numpy \u8d1f\u8d23 \uff0cPillow \u8d1f\u8d23\u56fe\u7247\u8bfb\u5199<\/p>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\">\u5728\u6b63\u6587\u5f00\u59cb\u4e4b\u524d\uff0c\u5148\u770b\u4e00\u4e0b\u6548\u679c\uff0c\u4e0b\u9762\u662f\u5355\u5f20\u56fe\u7247\u8f6c\u6362\u524d\u540e\u5bf9\u6bd4<\/p>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\">\u56fe\u4e00<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center;\"><img decoding=\"async\" style=\"display: block; margin-right: auto; margin-left: auto; height: auto !important;\" title=\"\u7528\u4e0d\u523020\u884c\u4ee3\u7801\u5236\u4f5c\u4e00\u4e2a \u201c\u624b\u7ed8\u98ce\u201d \u89c6\u9891\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2021\/04\/3-1618897316.png\" alt=\"\u7528\u4e0d\u523020\u884c\u4ee3\u7801\u5236\u4f5c\u4e00\u4e2a \u201c\u624b\u7ed8\u98ce\u201d \u89c6\u9891\" \/><\/figure>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\">\u56fe\u4e8c<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center;\"><img decoding=\"async\" style=\"display: block; margin-right: auto; margin-left: auto; height: auto !important;\" title=\"\u7528\u4e0d\u523020\u884c\u4ee3\u7801\u5236\u4f5c\u4e00\u4e2a \u201c\u624b\u7ed8\u98ce\u201d \u89c6\u9891\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2021\/04\/10-1618897316.png\" alt=\"\u7528\u4e0d\u523020\u884c\u4ee3\u7801\u5236\u4f5c\u4e00\u4e2a \u201c\u624b\u7ed8\u98ce\u201d \u89c6\u9891\" \/><\/figure>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\">\u56fe\u4e09<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center;\"><img decoding=\"async\" style=\"display: block; margin-right: auto; margin-left: auto; height: auto !important;\" title=\"\u7528\u4e0d\u523020\u884c\u4ee3\u7801\u5236\u4f5c\u4e00\u4e2a \u201c\u624b\u7ed8\u98ce\u201d \u89c6\u9891\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2021\/04\/4-1618897316.png\" alt=\"\u7528\u4e0d\u523020\u884c\u4ee3\u7801\u5236\u4f5c\u4e00\u4e2a \u201c\u624b\u7ed8\u98ce\u201d \u89c6\u9891\" \/><\/figure>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\">\u4e3a\u4e86\u589e\u52a0\u8da3\u5473\u6027\uff0c\u518d\u5c06\u8fd9\u6bb5\u4ee3\u7801\u5e94\u7528\u5230\u4e00\u4e2a\u89c6\u9891\u4e2d\uff0c\u65b0\u9c9c\u7684 \u201c\u624b\u7ed8\u98ce\u89c6\u9891\u201d \u51fa\u7089<\/p>\n<div class=\"bp-video\">\n<div class=\"player\"><iframe class=\"bp-iframe\" src=\"https:\/\/mp.weixin.qq.com\/mp\/readtemplate?t=pages\/video_player_tmpl&amp;action=mpvideo&amp;auto=0&amp;vid=wxv_1791045886060380161\" width=\"100%\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/div>\n<\/div>\n<p>\u00a0<\/p>\n<h4 style=\"margin-top: 30px; margin-bottom: 15px; font-weight: bold; font-size: 18px;\"><span style=\"display: inline-block; font-size: 0.9em; border-left: 5px solid #108ee9; padding: 3px 10px 1px;\">\u201c\u624b\u7ed8\u98ce\u201d\u5b9e\u73b0\u6b65\u9aa4<\/span><\/h4>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\">\u8bb2\u89e3\u4e4b\u524d\uff0c\u9700\u8981\u4e86\u89e3\u624b\u7ed8\u56fe\u50cf\u7684\u4e09\u4e2a\u4e3b\u8981\u7279\u70b9\uff1a<\/p>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101; word-spacing: 2px; letter-spacing: 1px; font-size: 15px;\">\u56fe\u7247\u9700\u4e3a\u7070\u5ea6\u56fe\uff0c\u662f\u5355\u901a\u9053\u7684\uff1b<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101; word-spacing: 2px; letter-spacing: 1px; font-size: 15px;\">\u8fb9\u7f18\u90e8\u5206\u7ebf\u6761\u8f83\u91cd\u6d82\u62b9\u4e3a\u9ed1\u8272\uff0c\u76f8\u540c\u6216\u76f8\u8fd1\u50cf\u7d20\u503c\u8f6c\u6362\u540e\u8d8b\u4e8e\u767d\u8272\uff1b<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101; word-spacing: 2px; letter-spacing: 1px; font-size: 15px;\">\u5728\u5149\u6e90\u6548\u679c\u7684\u52a0\u6301\u4e0b\uff0c\u7070\u5ea6\u53d8\u5316\u53ef\u6a21\u62df\u4eba\u7c7b\u89c6\u89c9\u7684\u8fdc\u8fd1\u6548\u679c<\/section>\n<\/li>\n<\/ul>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\"><strong style=\"color: #108ee9;\">\u8bfb\u53d6\u56fe\u7247\uff0c\u8f6c\u5316\u4e3a\u6570\u7ec4<\/strong><\/p>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\">\u56e0\u4e3a\u540e\u9762\u8981\u7528\u5230\u50cf\u7d20\u8ba1\u7b97\uff0c\u4e3a\u4e86\u65b9\u4fbf\uff0c\u4e8b\u5148\u5c06\u8bfb\u53d6\u540e\u7684\u56fe\u7247\u8f6c\u5316\u4e3a\u6570\u7ec4<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">a\u00a0=\u00a0np.asarray(Image.open(<span style=\"color: #98c379; line-height: 26px;\">\"Annie1.jpg\"<\/span>).convert(<span style=\"color: #98c379; line-height: 26px;\">'L'<\/span>)).astype(<span style=\"color: #98c379; line-height: 26px;\">'float'<\/span>)<br \/><\/code><\/pre>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\"><strong style=\"color: #108ee9;\">\u8ba1\u7b97 x,y,z \u8f74\u68af\u5ea6\u503c\uff0c\u5e76\u5f52\u4e00\u5316<\/strong><\/p>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\">\u521a\u624d\u63d0\u5230\u624b\u7ed8\u7167\u7247\u7684\u4e00\u4e2a\u7279\u70b9\uff0c\u5c31\u662f <strong style=\"color: #108ee9;\">\u624b\u7ed8\u7167\u7247\u5bf9\u8fb9\u7f18\u533a\u57df\u66f4\u52a0\u4fa7\u91cd<\/strong>\uff0c\u5b9a\u4f4d\u56fe\u7247\u8fb9\u7f18\u90e8\u5206\uff0c\u6700\u6709\u6548\u65b9\u5f0f\u5c31\u662f\u8ba1\u7b97\u68af\u5ea6\uff0c\u7528\u7070\u5ea6\u53d8\u5316\u6765\u6a21\u62df\u56fe\u7247\u8fdc\u8fd1\u6548\u679c\uff0cdepth \u8868\u793a\u9884\u8bbe\u6df1\u5ea6\uff0cz \u8f74\u9ed8\u8ba4\u68af\u5ea6\u4e3a 1<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">depth\u00a0=\u00a010.\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0(0-100)<\/span><br \/>grad\u00a0=\u00a0np.gradient(a)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u53d6\u56fe\u50cf\u7070\u5ea6\u7684\u68af\u5ea6\u503c<\/span><br \/>grad_x,\u00a0grad_y\u00a0=\u00a0grad\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5206\u522b\u53d6\u6a2a\u7eb5\u56fe\u50cf\u68af\u5ea6\u503c<\/span><br \/>grad_x\u00a0=\u00a0grad_x\u00a0*\u00a0depth\u00a0\/\u00a0100.<br \/>grad_y\u00a0=\u00a0grad_y\u00a0*\u00a0depth\u00a0\/\u00a0100.<br \/><\/code><\/pre>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\">\u5bf9\u68af\u5ea6\u503c\u5b8c\u6210\u5f52\u4e00\u5316\u64cd\u4f5c<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">A\u00a0=\u00a0np.sqrt(grad_x\u00a0**\u00a02\u00a0+\u00a0grad_y\u00a0**\u00a02\u00a0+\u00a01.)<br \/>uni_x\u00a0=\u00a0grad_x\u00a0\/\u00a0A<br \/>uni_y\u00a0=\u00a0grad_y\u00a0\/\u00a0A<br \/>uni_z\u00a0=\u00a01.\u00a0\/\u00a0A<br \/><\/code><\/pre>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\"><strong style=\"color: #108ee9;\">\u52a0\u5165\u5149\u6e90\u6548\u679c<\/strong><\/p>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\">\u624b\u7ed8\u98ce\u56fe\u7247\u9664\u4e86\u8ba1\u7b97\u68af\u5ea6\u503c\u4e4b\u5916\uff0c\u8fd8\u9700\u8981\u8003\u8651\u5149\u6e90\u5f71\u54cd\u3002\u5149\u6e90\u5165\u5c04\u7684\u89d2\u5ea6\u4e0d\u540c\u4f1a\u5bf9 x,y,z \u5404\u8f74\u4e0a\u7684\u68af\u5ea6\u503c\u6709\u4e0d\u540c\u7a0b\u5ea6\u7684\u5f71\u54cd\u3002\u6dfb\u52a0\u4e00\u4e2a\u6a21\u62df\u5149\u6e90\uff0c\u653e\u7f6e\u5728\u659c\u4e0a\u65b9\uff0c\u4e0e x , y \u5206\u522b\u5f62\u6210\u4e24\u4e2a\u5939\u89d2<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center;\"><img decoding=\"async\" style=\"display: block; margin-right: auto; margin-left: auto; height: auto !important;\" title=\"\u7528\u4e0d\u523020\u884c\u4ee3\u7801\u5236\u4f5c\u4e00\u4e2a \u201c\u624b\u7ed8\u98ce\u201d \u89c6\u9891\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2021\/04\/9-1618897316.png\" alt=\"\u7528\u4e0d\u523020\u884c\u4ee3\u7801\u5236\u4f5c\u4e00\u4e2a \u201c\u624b\u7ed8\u98ce\u201d \u89c6\u9891\" \/><\/figure>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\">\u5e76\u4e14\u8fd9\u4e24\u4e2a\u5939\u89d2\u662f\u901a\u8fc7\u5b9e\u9a8c\u5f97\u5230\u662f\u5df2\u77e5\u7684\uff0c\u7136\u540e\u6839\u636e\u6b63\u5f26\u4f59\u5f26\u51fd\u6570\u8ba1\u7b97\u51fa\u6700\u7ec8\u65b0\u7684\u50cf\u7d20\u503c<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">vec_el\u00a0=\u00a0np.pi\u00a0\/\u00a02.2\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5149\u6e90\u7684\u4fef\u89c6\u89d2\u5ea6,\u5f27\u5ea6\u503c<\/span><br \/>vec_az\u00a0=\u00a0np.pi\u00a0\/\u00a04.\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5149\u6e90\u7684\u65b9\u4f4d\u89d2\u5ea6,\u5f27\u5ea6\u503c<\/span><br \/>dx\u00a0=\u00a0np.cos(vec_el)\u00a0*\u00a0np.cos(vec_az)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5149\u6e90\u5bf9\u00a0x\u8f74\u7684\u5f71\u54cd<\/span><br \/>dy\u00a0=\u00a0np.cos(vec_el)\u00a0*\u00a0np.sin(vec_az)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5149\u6e90\u5bf9\u00a0y\u8f74\u7684\u5f71\u54cd<\/span><br \/>dz\u00a0=\u00a0np.sin(vec_el)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5149\u6e90\u5bf9z\u00a0\u8f74\u7684\u5f71\u54cd<\/span><br \/><br \/>b\u00a0=\u00a0255\u00a0*\u00a0(dx\u00a0*\u00a0uni_x\u00a0+\u00a0dy\u00a0*\u00a0uni_y\u00a0+\u00a0dz\u00a0*\u00a0uni_z)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5149\u6e90\u5f52\u4e00\u5316,8\u00a0255<\/span><br \/>b\u00a0=\u00a0b.clip(0,\u00a0255)<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5bf9\u50cf\u7d20\u503c\u4f4e\u4e8e0\uff0c\u9ad8\u4e8e255\u90e8\u5206\u505a\u622a\u65ad\u5904\u7406<\/span><br \/><\/code><\/pre>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\"><strong style=\"color: #108ee9;\">\u5bfc\u51fa\u56fe\u7247\uff0c\u5e76\u4fdd\u5b58<\/strong><\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">im.save(<span style=\"color: #98c379; line-height: 26px;\">\"Annie_shouhui.jpg\"<\/span>)<br \/><\/code><\/pre>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\">\u4ee5\u4e0b\u662f\u8be5\u6b65\u9aa4\u6d89\u53ca\u5230\u7684\u7684\u5168\u90e8\u4ee3\u7801<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">from\u00a0PIL\u00a0import\u00a0Image<br \/>import\u00a0numpy\u00a0as\u00a0np<br \/><br \/><br \/>a\u00a0=\u00a0np.asarray(Image.open(<span style=\"color: #98c379; line-height: 26px;\">\"Annie1.jpg\"<\/span>).convert(<span style=\"color: #98c379; line-height: 26px;\">'L'<\/span>)).astype(<span style=\"color: #98c379; line-height: 26px;\">'float'<\/span>)<br \/><br \/>depth\u00a0=\u00a010.\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0(0-100)<\/span><br \/>grad\u00a0=\u00a0np.gradient(a)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u53d6\u56fe\u50cf\u7070\u5ea6\u7684\u68af\u5ea6\u503c<\/span><br \/>grad_x,\u00a0grad_y\u00a0=\u00a0grad\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5206\u522b\u53d6\u6a2a\u7eb5\u56fe\u50cf\u68af\u5ea6\u503c<\/span><br \/>grad_x\u00a0=\u00a0grad_x\u00a0*\u00a0depth\u00a0\/\u00a0100.<br \/>grad_y\u00a0=\u00a0grad_y\u00a0*\u00a0depth\u00a0\/\u00a0100.<br \/>A\u00a0=\u00a0np.sqrt(grad_x\u00a0**\u00a02\u00a0+\u00a0grad_y\u00a0**\u00a02\u00a0+\u00a01.)<br \/>uni_x\u00a0=\u00a0grad_x\u00a0\/\u00a0A<br \/>uni_y\u00a0=\u00a0grad_y\u00a0\/\u00a0A<br \/>uni_z\u00a0=\u00a01.\u00a0\/\u00a0A<br \/><br \/>vec_el\u00a0=\u00a0np.pi\u00a0\/\u00a02.2\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5149\u6e90\u7684\u4fef\u89c6\u89d2\u5ea6,\u5f27\u5ea6\u503c<\/span><br \/>vec_az\u00a0=\u00a0np.pi\u00a0\/\u00a04.\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5149\u6e90\u7684\u65b9\u4f4d\u89d2\u5ea6,\u5f27\u5ea6\u503c<\/span><br \/>dx\u00a0=\u00a0np.cos(vec_el)\u00a0*\u00a0np.cos(vec_az)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5149\u6e90\u5bf9\u00a0x\u8f74\u7684\u5f71\u54cd<\/span><br \/>dy\u00a0=\u00a0np.cos(vec_el)\u00a0*\u00a0np.sin(vec_az)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5149\u6e90\u5bf9\u00a0y\u8f74\u7684\u5f71\u54cd<\/span><br \/>dz\u00a0=\u00a0np.sin(vec_el)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5149\u6e90\u5bf9z\u00a0\u8f74\u7684\u5f71\u54cd<\/span><br \/><br \/>b\u00a0=\u00a0255\u00a0*\u00a0(dx\u00a0*\u00a0uni_x\u00a0+\u00a0dy\u00a0*\u00a0uni_y\u00a0+\u00a0dz\u00a0*\u00a0uni_z)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5149\u6e90\u5f52\u4e00\u5316<\/span><br \/>b\u00a0=\u00a0b.clip(0,\u00a0255)<br \/><br \/>im\u00a0=\u00a0Image.fromarray(b.astype(<span style=\"color: #98c379; line-height: 26px;\">'uint8'<\/span>))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u91cd\u6784\u56fe\u50cf<\/span><br \/>im.save(<span style=\"color: #98c379; line-height: 26px;\">\"Annie_shouhui.jpg\"<\/span>)<\/code><\/pre>\n<h4 style=\"margin-top: 30px; margin-bottom: 15px; font-weight: bold; font-size: 18px;\">\u00a0<\/h4>\n<h4 style=\"margin-top: 30px; margin-bottom: 15px; font-weight: bold; font-size: 18px;\"><span style=\"display: inline-block; font-size: 0.9em; border-left: 5px solid #108ee9; padding: 3px 10px 1px;\">\u5236\u4f5c\u624b\u7ed8\u98ce\u89c6\u9891<\/span><\/h4>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\">\u56fe\u7247\u8f6c\u5316\u540e\u7684\u6548\u679c\u867d\u7136\u4e5f\u4e0d\u9519\uff0c\u4f46\u56fe\u7247\u6bd5\u7adf\u662f\u9759\u6001\u7684\uff0c\u4eba\u4f5c\u4e3a\u89c6\u89c9\u52a8\u7269\uff0c\u5982\u679c\u80fd\u505a\u6210\u52a8\u6001\u7684\u90a3\u518d\u597d\u4e0d\u8fc7\u4e86\uff0c\u77e5\u9053\u4e0a\u9762\u7684\u65b9\u6cd5\u4e4b\u540e\uff0c\u53ea\u9700\u5bf9\u89c6\u9891\u518d\u52a0\u4e0a\u4e00\u4e2a\u62c6\u5e27\u5408\u5e76\u64cd\u4f5c\uff0c\u5c31\u80fd\u5236\u4f5c\u4e00\u4e2a<strong style=\"color: #108ee9;\">\u624b\u7ed8\u98ce<\/strong>\u89c6\u9891\u6548\u679c\u3002<\/p>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\">\u9996\u5148\u6211\u4eec\u9700\u8981\u4e00\u4e2a\u5f85\u8f6c\u6362\u7684\u89c6\u9891\u6587\u4ef6\u3002\u8fd9\u91cc\u6211\u7528 you-get \u5de5\u5177\u5728 B \u7ad9\u4e0a\u627e\u4e86\u4e00\u4e2a\u89c6\u9891\uff0c\u4e0b\u8f7d\u4e86\u4e0b\u6765<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">you-get\u00a0--format=dash-flv\u00a0-o\u00a0.\/\u00a0https:\/\/www.bilibili.com\/video\/BV1tT4y1j7a9?from=search&amp;8014393453748720686<br \/><\/code><\/pre>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center;\"><img decoding=\"async\" style=\"display: block; margin-right: auto; margin-left: auto; height: auto !important;\" title=\"\u7528\u4e0d\u523020\u884c\u4ee3\u7801\u5236\u4f5c\u4e00\u4e2a \u201c\u624b\u7ed8\u98ce\u201d \u89c6\u9891\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2021\/04\/1-1618897316.png\" alt=\"\u7528\u4e0d\u523020\u884c\u4ee3\u7801\u5236\u4f5c\u4e00\u4e2a \u201c\u624b\u7ed8\u98ce\u201d \u89c6\u9891\" \/><\/figure>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\">\u4e0b\u8f7d\u5b8c\u4e4b\u540e\uff0c\u7528 OpenCV2 \u5bf9\u89c6\u9891\u8fdb\u884c\u5207\u5e27\u64cd\u4f5c\uff0c\u5c06\u89c6\u9891\u8f6c\u4e3a\u4e00\u5f20\u5f20\u56fe\u7247\uff0c\u540c\u65f6\u5bf9\u56fe\u7247\u8fdb\u884c\u624b\u7ed8\u98ce\u683c\u8f6c\u5316\uff0c\u518d\u5199\u51fa\u5230\u672c\u5730\u89c6\u9891\u6587\u4ef6\u4e2d<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">\u00a0vc\u00a0=\u00a0cv2.VideoCapture(video_path)<br \/>\u00a0\u00a0\u00a0\u00a0c\u00a0=\u00a00<br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"color: #c678dd; line-height: 26px;\">if<\/span>\u00a0vc.isOpened():<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0rval,frame\u00a0=\u00a0vc.read()<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0height,width\u00a0=\u00a0frame.shape[0],frame.shape[1]<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(height,\u00a0width)<br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"color: #c678dd; line-height: 26px;\">else<\/span>:<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0rval\u00a0=\u00a0False<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0height,width\u00a0=\u00a0960,1200<br \/><br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0jpg_list\u00a0=\u00a0[os.path.join('Pic_Directory\/',i)\u00a0for\u00a0i\u00a0in\u00a0os.listdir('Pic_Directory')\u00a0if\u00a0i.endswith('.jpg')]<\/span><br \/><br \/>\u00a0\u00a0\u00a0\u00a0fps\u00a0=\u00a024\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u89c6\u9891\u5e27\u7387<\/span><br \/>\u00a0\u00a0\u00a0\u00a0video_path1\u00a0=\u00a0<span style=\"color: #98c379; line-height: 26px;\">'.\/text.mp4'<\/span><br \/>\u00a0\u00a0\u00a0\u00a0video_writer\u00a0=\u00a0cv2.VideoWriter(video_path1,cv2.VideoWriter_fourcc(*<span style=\"color: #98c379; line-height: 26px;\">'mp4v'<\/span>),fps,(width,height))<br \/><br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"color: #c678dd; line-height: 26px;\">while<\/span>\u00a0rval:<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0rval,frame\u00a0=\u00a0vc.read()<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u8bfb\u53d6\u89c6\u9891\u5e27<\/span><br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0img\u00a0=\u00a0coonvert_jpg(Image.fromarray(frame))<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0frame_converted\u00a0=\u00a0np.array(img)<br \/><br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u8f6c\u5316\u4e3a\u4e09\u901a\u9053<\/span><br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0image\u00a0=\u00a0np.expand_dims(frame_converted,axis\u00a0=\u00a02)<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0result_arr\u00a0=\u00a0np.concatenate((image,image,image),axis\u00a0=\u00a0-1)<br \/><br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0video_writer.write(result_arr)<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(<span style=\"color: #98c379; line-height: 26px;\">'Sucessfully\u00a0Conveted---------{}'<\/span>.format(c))<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0c\u00a0=\u00a0c\u00a0+\u00a01<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: #c678dd; line-height: 26px;\">if<\/span>\u00a0c\u00a0&gt;=\u00a03000:<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">break<\/span><br \/>\u00a0\u00a0\u00a0\u00a0video_writer.release()<br \/><\/code><\/pre>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\">\u5728\u56fe\u7247\u5e8f\u5217\u63d0\u53d6\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4e00\u70b9\uff0c\u56e0\u4e3a\u8f6c\u5316\u540e\u7684\u56fe\u7247\u662f\u5355\u901a\u9053\u7684\uff0c\u76f4\u63a5\u501f\u52a9 OpenCV \u751f\u6210\u89c6\u9891\u5e8f\u5217\u662f\u65e0\u6cd5\u64ad\u653e\u7684\uff0c\u9700\u589e\u52a0\u4e00\u4e2a\u6b65\u9aa4<strong style=\"color: #108ee9;\">\u5355\u901a\u9053\u8f6c\u5316\u4e3a\u4e09\u901a\u9053\uff01<\/strong><\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u8f6c\u5316\u4e3a\u4e09\u901a\u9053<\/span><br \/>\u00a0image\u00a0=\u00a0np.expand_dims(frame_converted,axis\u00a0=\u00a02)<br \/>\u00a0result_arr\u00a0=\u00a0np.concatenate((image,image,image),axis\u00a0=\u00a0-1)<br \/><\/code><\/pre>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\">\u60f3\u8ba9\u751f\u6210\u7684\u89c6\u9891\u66f4\u6709\u611f\u89c9\u7684\u8bdd\u53ef\u4ee5\u6dfb\u52a0\u4e00\u4e2a\u80cc\u5f71\u97f3\u4e50\uff0c\u501f\u52a9\u526a\u8f91\u8f6f\u4ef6\u3001Python \u90fd\u53ef\u4ee5\u5b9e\u73b0\u3002<\/p>\n<h4 style=\"margin-top: 30px; margin-bottom: 15px; font-weight: bold; font-size: 18px;\"><span style=\"display: inline-block; font-size: 0.9em; border-left: 5px solid #108ee9; padding: 3px 10px 1px;\">\u5c0f\u7ed3<\/span><\/h4>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\">\u672c\u6587\u4e3b\u8981\u4ecb\u7ecd\u4e86\u5982\u4f55\u7528 Python\u5c06\u4e00\u5f20\u56fe\u7247\u8f6c\u5316\u4e3a\u624b\u7ed8\u98ce\u683c\uff0c\u4ee3\u7801\u91cf\u4e0d\u591a\uff0c\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u5e94\u7528\u3002\u4e0d\u8fc7\u80cc\u540e\u7684\u539f\u7406\u5e76\u4e0d\u7b80\u5355\uff0c\u6d89\u53ca\u6570\u5b66\u3001\u7269\u7406\u76f8\u5173\u7684<span style=\"color: #3e3e3e; letter-spacing: 1px; text-align: left; word-spacing: 1px;\">\u77e5<\/span><span style=\"color: #3e3e3e; letter-spacing: 1px; text-align: left; word-spacing: 1px;\">\u8bc6\u70b9<\/span>\u3002<\/p>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\"><span style=\"color: #3e3e3e; letter-spacing: 1px; text-align: left; word-spacing: 1px;\">\u6587\u4e2d\u6d89\u53ca\u5230\u7684\u6e90\u7801\u5927\u90e8\u5206\u5176\u5b9e\u90fd\u5df2\u7ecf\u8d34\u5728\u6587\u7ae0\uff0c\u4f46\u4e3a\u4e86\u65b9\u4fbf\u8d77\u89c1\uff0c\u6211\u5df2\u7ecf\u5c06\u6570\u636e\u548c\u6e90\u7801\u6574\u5408\u5728\u4e00\u8d77\uff0c\u60f3\u83b7\u53d6\u7684\u540c\u5b66\u53ef\u4ee5\uff0c\u8bf7\u5728\u516c\u53f7\u540e\u53f0\u56de\u590d\u5173\u952e\u5b57\uff1a<\/span><span style=\"letter-spacing: 1px; text-align: left; word-spacing: 1px; color: #0080ff;\"><strong>\u624b\u7ed8<\/strong><\/span><\/p>\n<p style=\"word-spacing: 1px; letter-spacing: 1px; font-size: 15px; color: #3e3e3e; margin-top: 25px; margin-bottom: 25px;\">\u5982\u679c\u6587\u7ae0\u5bf9\u4f60\u6709\u5e2e\u52a9\uff0c\u6b22\u8fce\u8f6c\u53d1\/\u70b9\u8d5e\/\u6536\u85cf~<\/p>\n<p style=\"margin-top: 25px;\"><span style=\"font-size: 14px; color: #797baa;\">\u4f5c\u8005\uff1azeroing<\/span><\/p>\n<section><span style=\"font-size: 14px; color: #797baa;\">\u6765\u6e90\uff1a\u5c0f\u5f20Python<\/span><\/section>\n<section><\/section>\n<\/section>\n<\/div>\n\n\n<p>\u8f6c\u81ea\uff1ahttps:\/\/mp.weixin.qq.com\/s\/dGP5ec5lgNF9QpDnOLJBpQ<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u5206\u4eab\u7684\u6587\u7ae0\u4e0e\u8ba1\u7b97\u673a\u89c6\u89c9\u76f8\u5173\uff0c\u7528\u4e0d\u5230 20 \u884cPython\u4ee3\u7801\u5c06\u4e00\u5f20\u5b9e\u62cd\u56fe\u7247\u8f6c\u5316\u4e3a\u624b\u7ed8\u98ce\uff0c\u65e0\u9700\u5bf9\u56fe\u7247\u8fdb\u884c\u4efb\u4f55 &hellip; <a href=\"http:\/\/www.zhushiyao.com\/?p=63474\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201c\u7528\u4e0d\u523020\u884c\u4ee3\u7801\u5236\u4f5c\u4e00\u4e2a \u201c\u624b\u7ed8\u98ce\u201d \u89c6\u9891\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[8],"_links":{"self":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts\/63474"}],"collection":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=63474"}],"version-history":[{"count":2,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts\/63474\/revisions"}],"predecessor-version":[{"id":63484,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts\/63474\/revisions\/63484"}],"wp:attachment":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=63474"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=63474"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=63474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}