Camera Capture

935
8
Jump to solution
11-06-2019 01:42 PM
jaykapalczynski
Frequent Contributor

I took the Camera Capture template from AppStudio for ArcGIS and uploaded it.  I then went into Player on my phone and took a picture.  I cannot see that image saved anywhere.  I want to take this image and attach it to a feature with attributes but I first need the actual image to be captured....Am I doing something wrong?

Does this sample not capture and save to picture?  Does it place it in limbo or somewhere that I can then save it somewhere?  Sort of confused how this is working.  Any ideas?

0 Kudos
1 Solution

Accepted Solutions
jaykapalczynski
Frequent Contributor

Everything was correct in my last example but needed to change it to this

ANY questions please ask....

WRONG

if (selectedFeature.loadStatus === Enums.LoadStatusLoaded) {                              
     selectedFeature.attachments.addAttachment(imagesFolder.filePath, "application/octet-stream", "captureTest.jpg");
}‍‍‍‍‍‍

CORRECT

if (selectedFeature.loadStatus === Enums.LoadStatusLoaded) {                              
     selectedFeature.attachments.addAttachment(camera.imageCapture.capturedImagePath, "application/octet-stream", "captureTest.jpg");
}‍‍‍

‍‍‍‍

View solution in original post

8 Replies
ErwinSoekianto
Esri Regular Contributor

Jay, 

The picture is stored at the path highlighted on the screen. See the image below. 

Thank you,

Erwin

0 Kudos
jaykapalczynski
Frequent Contributor

Thats what I thought....common sense right? ahahah

I cant find the image anywhere on my phone after taking the image....will check again....

0 Kudos
jaykapalczynski
Frequent Contributor

Can you go to that location on your phone and see the image file there?

I cannot find the image anywhere on my phone after taking the picture....hmmmm

0 Kudos
jaykapalczynski
Frequent Contributor

Erwin

Are you actually able to see the image on your mobile device?

0 Kudos
ErwinSoekianto
Esri Regular Contributor

Jay, 

That path on iOS, /var/mobile/Containers/Data/Application/... is sand-box private application path. You can not just go to the location. But within the same application, you can refer to it using the path, and do things programmatically, such as display it and upload it as an attachment of a feature. 

The same logic also applies in the QuickReport template where user can take pictures or videos, then upload them as attachments to a feature. 

Thank you,

Erwin

0 Kudos
jaykapalczynski
Frequent Contributor

OK....From the example onClicked in the camera window I see this:

MouseArea {
   anchors.fill: parent;
   onClicked: {              
       camera.imageCapture.captureToLocation(imagesFolder.filePath("captureTest.jpg"));
   }
}‍‍‍‍‍‍

FileFolder {
    id: imagesFolder
}

I am then trying to grab that image and attach it to a selected feature.....but something is not working as it does not upload the image to that feature....

if (selectedFeature.loadStatus === Enums.LoadStatusLoaded) {                              
     selectedFeature.attachments.addAttachment(imagesFolder.filePath, "application/octet-stream", "captureTest.jpg");
}‍‍‍‍

Does the syntax look correct?  I can do this with the example that pops up the dialog box and I select the image from my phone and that works fine although the code is more like this

Having a hard time integrating the two ways to attach an image.  

ANY IDEAS?

        DocumentDialog {
            id: fileDialog

            function doAddAttachment(){
                if (selectedFeature.loadStatus === Enums.LoadStatusLoaded) {
                    selectedFeature.onLoadStatusChanged.disconnect(doAddAttachment);
                    selectedFeature.attachments.addAttachment(fileDialog.filePath, "application/octet-stream", fileInfo.fileName);
                }
            }

            onAccepted: {
                // add the attachment to the feature table
                fileInfo.url = filePath
                if (selectedFeature.loadStatus === Enums.LoadStatusLoaded) {
                    selectedFeature.attachments.addAttachment(filePath, "application/octet-stream", fileInfo.fileName);
                } else {
                    selectedFeature.onLoadStatusChanged.connect(doAddAttachment);
                    selectedFeature.load();
                }
                console.log(filePath)
            }
        }
        //! [EditFeatures add attachment from a file dialog]
        MessageDialog {
            id: msgDialog
        }
        // file info used for obtaining the file name
        FileInfo {
            id: fileInfo
        }
        //Show storage permission pop-up on Android
        FileFolder {
            id: fileFolder
            path: AppFramework.userHomePath
        }
        Component.onCompleted: {
            fileFolder.makeFolder()
        }
0 Kudos
jaykapalczynski
Frequent Contributor

THINK I JUST GOT IT...ONE Second testing now... really excited.

0 Kudos
jaykapalczynski
Frequent Contributor

Everything was correct in my last example but needed to change it to this

ANY questions please ask....

WRONG

if (selectedFeature.loadStatus === Enums.LoadStatusLoaded) {                              
     selectedFeature.attachments.addAttachment(imagesFolder.filePath, "application/octet-stream", "captureTest.jpg");
}‍‍‍‍‍‍

CORRECT

if (selectedFeature.loadStatus === Enums.LoadStatusLoaded) {                              
     selectedFeature.attachments.addAttachment(camera.imageCapture.capturedImagePath, "application/octet-stream", "captureTest.jpg");
}‍‍‍

‍‍‍‍