{"id":535,"date":"2019-07-08T01:46:42","date_gmt":"2019-07-07T16:46:42","guid":{"rendered":"https:\/\/dalomo.net\/blog\/?p=535"},"modified":"2019-07-15T18:09:04","modified_gmt":"2019-07-15T09:09:04","slug":"raspberry-pi-zero-wh%e3%81%a7%e8%b1%86%e8%8b%97%e3%81%ae%e5%ae%9a%e7%82%b9%e3%82%ab%e3%83%a1%e3%83%a9%e4%bd%9c%e3%82%8a%e3%81%9f%e3%81%84%e2%91%a3picamera-cron%e7%b7%a8","status":"publish","type":"post","link":"https:\/\/dalomo.net\/blog\/2019\/07\/08\/535\/","title":{"rendered":"Raspberry Pi Zero WH\u3067\u8c46\u82d7\u306e\u5b9a\u70b9\u30ab\u30e1\u30e9\u4f5c\u308a\u305f\u3044\u2463picamera, cron\u7de8"},"content":{"rendered":"<h1>picamera<\/h1>\n<p>raspistill\u3067\u64ae\u5f71\u3067\u304d\u308b\u306e\u306f\u5206\u304b\u3063\u305f\u3051\u3069\u3001\u3058\u3083\u3042\u3069\u3046\u3084\u3063\u3066\u30d7\u30ed\u30b0\u30e9\u30e0\u7d44\u3080\u3093\u3060\u308d\u3001\u3068\u306a\u308b\u3002\u3084\u308a\u65b9\u306f\u8907\u6570\u3042\u308b\u307f\u305f\u3044\u3067\u3001\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u4f7f\u3063\u305f\u308a\u3042\u308b\u307f\u305f\u3044\u306a\u3093\u3060\u3051\u3069\u3001Python\u3067\u30ab\u30e1\u30e9\u3092\u64cd\u4f5c\u3067\u304d\u308b\u307f\u305f\u3044\u3002Python\u3084\u3063\u305f\u3053\u3068\u306a\u3044\u3051\u3069\u3001\u3084\u3063\u3066\u307f\u305f\u3044\u306e\u3067\u3053\u3063\u3061\u306b\u3057\u3088\u3046\u3068\u601d\u3063\u305f\u3002<\/p>\n<p><a href=\"https:\/\/picamera.readthedocs.io\/en\/release-1.13\/\">https:\/\/picamera.readthedocs.io\/en\/release-1.13\/<\/a><\/p>\n<p>\u3053\u308c\u306d\u3002\u3053\u3053\u306b\u66f8\u3044\u3066\u3042\u308b\u3068\u304a\u308a\u3067\u306f\u3042\u308b\u3093\u3060\u3051\u3069\u3001\u30e1\u30e2\u30e1\u30e2\u3002<\/p>\n<h2>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n<p>\u306a\u3093\u304b\u6700\u521d\u304b\u3089\u5165\u3063\u3066\u308b\u3089\u3057\u3044\u3093\u3060\u3051\u3069\u3001\u3068\u308a\u3042\u3048\u305a<\/p>\n<pre class=\"shell\">$ sudo apt-get install python-picamera<\/pre>\n<p>\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3002<\/p>\n<p>\u305d\u3046\u3044\u3048\u3070\u3001\u5165\u3063\u3066\u308bPython\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u77e5\u3089\u3093\u304b\u3063\u305f\u306e\u3067<\/p>\n<pre class=\"shell\">$ python --version\r\nPython 2.7.13\r\n$ python3 --version\r\nPython 3.5.3<\/pre>\n<p>\u3060\u3063\u305f\u3002\u9055\u3044\u306f\u77e5\u308a\u307e\u305b\u3093\u3002<\/p>\n<h2>\u64ae\u5f71\u3057\u3066\u3001\u65e5\u4ed8\u6642\u9593\u540d\u3067\u4fdd\u5b58<\/h2>\n<pre class=\"python\">import picamera\r\nimport datetime\r\nfrom time import sleep\r\n\r\nnow = datetime.datetime.now()\r\ndir_path = '\/home\/pi\/nas\/'\r\nfile_name = now.strftime('%Y%m%d%H%M%S')\r\n\r\nwith picamera.PiCamera() as camera:\r\n    sleep(5)\r\n    camera.hflip = True\r\n    camera.vflip = True\r\n    camera.capture(dir_path+file_name+'.jpg')<\/pre>\n<p>\u307b\u307c\u30b3\u30d4\u30da\u306a\u308f\u3051\u3060\u304c\u3002\u3042\u308b\u7a0b\u5ea6\u8aad\u3093\u3067\u3053\u3046\u3002<\/p>\n<h3>1-3\u884c\u76ee<\/h3>\n<p>import\u3063\u3066\u30fc\u306e\u304c\u30a2\u30d7\u30ea\u3068\u304b\u3067\u3082\u4f7f\u3063\u3066\u305f\u3042\u306eimport\u306a\u3093\u3060\u308d\u3046\u3002from \u2026 import \uff5e \u3063\u3066\u306e\u306f\u3001\u2026\u304b\u3089\uff5e\u3092import\u3059\u308b\u3063\u3066\u610f\u5473\u307f\u305f\u3044\u3002time\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u306fsleep\u95a2\u6570\u4ee5\u5916\u306b\u3082\u8272\u3005\u3042\u308b\u3051\u3069\u3001\u4eca\u56de\u4f7f\u3046\u306e\u306fsleep\u3060\u3051\u3060\u304b\u3089\u3063\u3066\u3053\u3068\u306a\u306e\u304b\u306a\u3002time\u3060\u3051\u3060\u3068\u99c4\u76ee\u306a\u3093\u3060\u308d\u3046\u304b\u3002\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u7684\u306a\u30a2\u30ec\u304b\u3057\u3089\u3002<\/p>\n<h3>5-7\u884c\u76ee<\/h3>\n<p>Python\u306f\u5909\u6570\u306e\u578b\u306e\u5ba3\u8a00\u3057\u306a\u304f\u3066\u3044\u3044\u307f\u305f\u3044\u3002VBA\u3067\u3044\u3046Variant\u578b\u307f\u305f\u3044\u306a\u3082\u3093\u306a\u306e\u304b\u306a\u3002\u3061\u3087\u3063\u3068\u9055\u3046\u304b\u3001\u52d5\u7684\u578b\u4ed8\u3051\u3063\u3066\u3044\u3046\u3093\u3060\u3063\u3066\u3002datetime.datetime.now()\u3067\u73fe\u5728\u6642\u523b\u3092\u53d6\u5f97\u3067\u304d\u308b\u3002datetime\u304c\u9023\u7d9a\u3057\u3066\u308b\u306e\u304c\u3061\u3087\u3063\u3068\u3042\u308c\u3060\u306a\u3063\u3066\u601d\u3063\u305f\u5834\u5408\u306f\u3001import\u306e\u3068\u3053\u308d\u3092<\/p>\n<pre class=\"python\">from datetime import datetime<\/pre>\n<p>\u3068\u3057\u3066\u3042\u3052\u308b\u3068datetime.now()\u3067\u53d6\u5f97\u3067\u304d\u308b\u307f\u305f\u3044\u3002\u3053\u306e\u6642\u306e\u623b\u308a\u5024\u306fdatetime\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u6b21\u306bstrftime\u3067\u6587\u5b57\u5217\u578b\u306b\u5909\u63db\u3057\u3066\u3042\u3052\u308b\u3002%Y%m%d%H%M%S\u3063\u3066\u3044\u3046\u306e\u304c\u66f8\u5f0f\u306e\u30b3\u30fc\u30c9\u3067<\/p>\n<ul>\n<li>%Y \u2026 \u897f\u66a6 (4\u6841) \u306e 10 \u9032\u8868\u8a18\u3092\u8868\u3057\u307e\u3059\u3002<\/li>\n<li>%m \u2026 0\u57cb\u3081\u3057\u305f10\u9032\u6570\u3067\u8868\u8a18\u3057\u305f\u6708\u3002<\/li>\n<li>%d \u2026 0\u57cb\u3081\u3057\u305f10\u9032\u6570\u3067\u8868\u8a18\u3057\u305f\u6708\u4e2d\u306e\u65e5\u306b\u3061\u3002<\/li>\n<li>%H \u2026 0\u57cb\u3081\u3057\u305f10\u9032\u6570\u3067\u8868\u8a18\u3057\u305f\u6642 (24\u6642\u9593\u8868\u8a18)\u3002<\/li>\n<li>%M \u2026 0\u57cb\u3081\u3057\u305f10\u9032\u6570\u3067\u8868\u8a18\u3057\u305f\u5206\u3002<\/li>\n<li>%S \u2026 0\u57cb\u3081\u3057\u305f10\u9032\u6570\u3067\u8868\u8a18\u3057\u305f\u79d2\u3002<\/li>\n<\/ul>\n<p>\u3067\u3059\u3063\u3066\u3002\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306f<a href=\"https:\/\/docs.python.org\/ja\/3.6\/library\/datetime.html#strftime-and-strptime-behavior\">\u3053\u3061\u3089 <\/a>\u3002\u3067\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u30d1\u30b9\u3068\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u5909\u6570\u306b\u4ee3\u5165\u3057\u3068\u304f\u3002<\/p>\n<h3>9-13\u884c\u76ee<\/h3>\n<p>with\u6587\u3060\u3002VBA\u3067\u3082\u3042\u308b\u306a\u3002\u66f8\u304d\u65b9\u3061\u3087\u3063\u3068\u9055\u3046\u3051\u3069\u3001\u610f\u5473\u5408\u3044\u3082\u4f3c\u305f\u611f\u3058\u306a\u3093\u3060\u308d\u304b?\u3071\u3063\u3068\u898bwith \u2026 as \uff5e\u3067\u3001\u2026\u3092\uff5e\u3068\u3057\u3066\u6271\u3048\u308b\u611f\u3058\u306b\u306a\u308b\u3063\u307d\u3044\u3093\u3060\u3051\u3069\u3002\u4ed6\u306e\u30b5\u30a4\u30c8\u898b\u305f\u3051\u3069\u30d5\u30a1\u30a4\u30eb\u306e\u5165\u51fa\u529b\u3084\u3089\u30aa\u30fc\u30d7\u30f3\u30fb\u30af\u30ed\u30fc\u30ba\u3084\u3089\u3067\u306a\u3093\u3060\u304b\u3088\u304f\u5206\u304b\u3093\u306a\u304b\u3063\u305f\u3002\u3053\u308c\u3092\u7406\u89e3\u3059\u308b\u6bb5\u968e\u306b\u306a\u3044\u6c17\u304c\u3059\u308b\u3002\u307e\u3041\u305d\u308c\u306f\u305d\u308c\u3068\u3057\u3066\u3002sleep\u3067\u30ab\u30e1\u30e9\u306e\u8d77\u52d5\u6e96\u5099\u3002\u30ab\u30e1\u30e9\u306e\u8a2d\u7f6e\u65b9\u5411\u304c\u4e0a\u4e0b\u9006\u3067\u3001\u9006\u3055\u307e\u306b\u64ae\u5f71\u3055\u308c\u305f\u306e\u3067\u3001hflip, vflip\u3067\u3072\u3063\u304f\u308a\u8fd4\u3057\u3066\u3042\u3052\u308b\u3002capture\u3067\u64ae\u5f71\u3001\u5f15\u6570\u306b\u30d1\u30b9\u3068\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u6307\u5b9a\u3057\u3066\u3042\u3052\u308b\u3068\u3002\u3067\u304d\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u3068\u308a\u3042\u3048\u305anas\u306e\u30d5\u30a9\u30eb\u30c0\u306btest.py\u3063\u3066\u540d\u524d\u3067\u4fdd\u5b58\u3057\u305f\u3002\u305d\u3093\u3067<\/p>\n<pre class=\"shell\">$ sudo python \/home\/pi\/nas\/test.py<\/pre>\n<p>\u3063\u3066\u3059\u308b\u3068\u2026<\/p>\n<p><a href=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/07\/20190707185300.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-547\" src=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/07\/20190707185300-300x200.jpg\" alt=\"\" width=\"300\" height=\"200\" srcset=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/07\/20190707185300-300x200.jpg 300w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/07\/20190707185300.jpg 720w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u64ae\u308c\u305f!!!\u3059\u3052\u30fc\u3059\u3052\u30fc<\/p>\n<p>\u30d4\u30f3\u307c\u3051\u3057\u3066\u308b\u306d\u3002\u307e\u3041\u3044\u3063\u304b\u3002<\/p>\n<h2>cron\u3067\u5b9a\u671f\u5b9f\u884c<\/h2>\n<p>linux\u306b\u306f\u5b9a\u671f\u5b9f\u884c\u7528\u306e\u4ed5\u7d44\u307f\u304c\u3042\u308b\u305d\u3046\u3067\u3001\u305d\u308c\u3092cron\u3066\u3044\u3046\u307f\u305f\u3044\u3002VPS\u4f7f\u3063\u305f\u3068\u304d\u306b\u3061\u3087\u3063\u3068\u3060\u3051\u3084\u3063\u305f\u6c17\u304c\u3059\u308b\u3002\u306a\u3093\u3060\u3063\u3051\u8a3c\u660e\u66f8\u53d6\u5f97\u3059\u308b\u3068\u304d\u3060\u3063\u305f\u304b\u306a\u3002\u307e\u3041\u3001\u3053\u308c\u306f\u3082\u3046\u30b3\u30d4\u30da\u3002<\/p>\n<pre class=\"shell\">$ sudo crontab -e<\/pre>\n<p>\u3053\u308c\u3067\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u307f\u305f\u3044\u306a\u306e\u304c\u958b\u3051\u308b\u306e\u3067\u3001#\u304c\u3064\u3044\u3066\u306a\u3044\u6700\u7d42\u884c\u306b<\/p>\n<pre class=\"shell\">0-59\/10 * * * * python \/home\/pi\/nas\/test.py<\/pre>\n<p>\u3068\u8ffd\u8a18\u3057\u305f\u3002\u30d5\u30a1\u30a4\u30eb\u540dtest\u306e\u307e\u3093\u307e\u3060\u3002\u3042\u3068<\/p>\n<pre class=\"shell\">$ sudo chown root:root test.py<\/pre>\n<p>\u3063\u3066\u3084\u3063\u3066\u6240\u6709\u8005\u5909\u66f4\u3057\u305f\u3002\u3067\u3001\u66ab\u304f\u5f85\u3064\u3068\u2026<\/p>\n<p><a href=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/07\/time.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-548\" src=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/07\/time-300x213.png\" alt=\"\" width=\"300\" height=\"213\" srcset=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/07\/time-300x213.png 300w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/07\/time-768x545.png 768w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/07\/time.png 836w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u30d5\u30a1\u30a4\u30eb\u304c\u3044\u3063\u3071\u3044\u8ffd\u52a0\u3055\u308c\u3066\u304a\u308a\u307e\u3059\u305e!!!\u3044\u3044\u611f\u3058\u3067\u3059\u3002\u3053\u308c\u3067\u8c46\u82d7\u3061\u3083\u3093\u304c\u3044\u3063\u3071\u3044\u306b\u6210\u9577\u3057\u305f\u3089\u52d5\u753b\u4f5c\u308c\u3070\u3044\u3044\u3093\u3060\u3002\u308f\u3063\u304f\u308f\u304f\uff5e<\/p>\n<h2>\u53c2\u8003<\/h2>\n<p><a href=\"https:\/\/deviceplus.jp\/hobby\/raspberrypi_entry_043\/\">https:\/\/deviceplus.jp\/hobby\/raspberrypi_entry_043\/<\/a><\/p>\n<p><a href=\"https:\/\/www.sejuku.net\/blog\/21474\">https:\/\/www.sejuku.net\/blog\/21474<\/a><\/p>\n<p><a href=\"https:\/\/qiita.com\/Usek\/items\/d681c6b95d7bea6b3250\">https:\/\/qiita.com\/Usek\/items\/d681c6b95d7bea6b3250<\/a><\/p>\n<p><a href=\"https:\/\/qiita.com\/mykysyk@github\/items\/e15d7b2b1a988b8e29d4\">https:\/\/qiita.com\/mykysyk@github\/items\/e15d7b2b1a988b8e29d4<\/a><\/p>\n<p><a href=\"https:\/\/note.nkmk.me\/python-datetime-usage\/\">https:\/\/note.nkmk.me\/python-datetime-usage\/<\/a><\/p>\n<p><a href=\"https:\/\/qiita.com\/tossh\/items\/e135bd063a50087c3d6a\">https:\/\/qiita.com\/tossh\/items\/e135bd063a50087c3d6a<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>picamera raspistill\u3067\u64ae\u5f71\u3067\u304d\u308b\u306e\u306f\u5206\u304b\u3063\u305f\u3051\u3069\u3001\u3058\u3083\u3042\u3069\u3046\u3084\u3063\u3066\u30d7\u30ed\u30b0\u30e9\u30e0\u7d44\u3080\u3093\u3060\u308d\u3001\u3068\u306a\u308b\u3002\u3084\u308a\u65b9\u306f\u8907\u6570\u3042\u308b\u307f\u305f\u3044\u3067\u3001\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u4f7f\u3063\u305f\u308a\u3042\u308b\u307f\u305f\u3044\u306a\u3093\u3060\u3051\u3069\u3001Python\u3067\u30ab\u30e1\u30e9\u3092\u64cd\u4f5c\u3067\u304d\u308b\u307f &hellip; <a href=\"https:\/\/dalomo.net\/blog\/2019\/07\/08\/535\/\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":547,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[8],"tags":[50,49,47],"class_list":["post-535","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-8","tag-python","tag-raspberry-pi-zero-wh","tag-47"],"_links":{"self":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/535","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/comments?post=535"}],"version-history":[{"count":4,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/535\/revisions"}],"predecessor-version":[{"id":565,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/535\/revisions\/565"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/media\/547"}],"wp:attachment":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/media?parent=535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/categories?post=535"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/tags?post=535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}