{"id":6738,"date":"2019-10-23T09:44:41","date_gmt":"2019-10-23T13:44:41","guid":{"rendered":"https:\/\/blogs.mathworks.com\/community\/?p=6738"},"modified":"2019-10-24T15:55:32","modified_gmt":"2019-10-24T19:55:32","slug":"acquire-images-from-your-device-camera-with-matlab-mobile","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/community\/2019\/10\/23\/acquire-images-from-your-device-camera-with-matlab-mobile\/","title":{"rendered":"Acquire Images from Your Device Camera with MATLAB Mobile"},"content":{"rendered":"<p><strong>Bringing Your Images and MATLAB Mobile Closer Together<\/strong><\/p>\n<p>In our <a href=\"https:\/\/blogs.mathworks.com\/community\/2019\/03\/07\/upload-photos-from-your-image-gallery-to-matlab-drive\/\">last blog post<\/a>, we started laying out our first phase of features that brought your images and MATLAB Mobile closer together. By enabling direct uploads to MATLAB Drive from your image gallery (and any application that has a \u2018Share\u2019 affordance), processing your images using MATLAB just became easier.<\/p>\n<p>While this provided a way to get your images into the app, we still had no ways to support in-app workflows, especially for acquiring live images (as opposed to the ones already in your gallery). Don\u2019t take my word for it, this was the first comment we got on that blog post:<\/p>\n<p><a href=\"https:\/\/blogs.mathworks.com\/community\/files\/Blog_Comment.png\"><img decoding=\"async\" loading=\"lazy\" width=\"789\" height=\"131\" class=\"aligncenter size-full wp-image-6758\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/Blog_Comment.png\" alt=\"\" \/><\/a><\/p>\n<p>In today\u2019s blog, we would like to describe phase two of our camera integration: access to the device camera from within the app.<\/p>\n<p><strong>Acquire Images from the &#8216;Files&#8217; Tab<\/strong><\/p>\n<p>One way to acquire images is to do so through our UI affordance. This can be accomplished through 4 simple steps, as illustrated below. To begin, select the \u2018+\u2019 affordance from the \u2018Files\u2019 tab and then select \u2018Camera\u2019.<\/p>\n<p><a href=\"https:\/\/blogs.mathworks.com\/community\/files\/Acquire_Images.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-6744\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/Acquire_Images.png\" alt=\"\" width=\"849\" height=\"479\" \/><\/a><\/p>\n<p>When you tap on \u2018Use Photo\u2019 in step 4, your image is automatically saved to your MATLAB Drive (in the same folder as you were on in step 1). This post focuses on images, but as you can see in Step 3, you can acquire videos as well.<\/p>\n<p>To use images from your Image Gallery, you need just a small tweak: in step 2, select \u2018Photos\u2019 and follow the UI navigation.<\/p>\n<p><strong>Acquire Images Using MATLAB Code<\/strong><\/p>\n<p>The workflow we described works if you want to take a photo and then plug it into your code. But what if you want the image acquisition to be a part of your code? We have you covered. The existing sensor functionality has been broadened to include access to your front- and rear-facing cameras. I can share a similar workflow diagram as the previous section\u2026 but a video is worth a thousand images (I think)! Here\u2019s one created by my colleague, Carlos Sanchis, that covers this functionality:<\/p>\n<p><div style=\"width: 608px;\" class=\"wp-video\"><!--[if lt IE 9]><script>document.createElement('video');<\/script><![endif]-->\n<video class=\"wp-video-shortcode\" id=\"video-6738-1\" width=\"608\" height=\"1080\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/Acquire_Images_MATLAB_Code.mp4?_=1\" \/><a href=\"https:\/\/blogs.mathworks.com\/community\/files\/Acquire_Images_MATLAB_Code.mp4\">https:\/\/blogs.mathworks.com\/community\/files\/Acquire_Images_MATLAB_Code.mp4<\/a><\/video><\/div><\/p>\n<p>In a nutshell: the \u2018mobiledev\u2019 object also allows you to connect to your device camera, and the SNAPSHOT command lets you acquire a single frame from your device camera.<\/p>\n<p><strong>Your Turn<\/strong><\/p>\n<p>How are you using MATLAB Mobile to acquire and process your images? Built any image classifiers yet? Let us know in the comments below.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/community\/files\/Acquire_Images.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div>\n<p>Bringing Your Images and MATLAB Mobile Closer Together<br \/>\nIn our last blog post, we started laying out our first phase of features that brought your images and MATLAB Mobile closer together. By enabling&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/community\/2019\/10\/23\/acquire-images-from-your-device-camera-with-matlab-mobile\/\">read more >><\/a><\/p>\n","protected":false},"author":74,"featured_media":6744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[54],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/6738"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/users\/74"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/comments?post=6738"}],"version-history":[{"count":8,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/6738\/revisions"}],"predecessor-version":[{"id":6766,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/6738\/revisions\/6766"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/media\/6744"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/media?parent=6738"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/categories?post=6738"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/tags?post=6738"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}