Main Virtual Tours SC2 Linux

How to delete an image as soon as it's taken

Hello,

I’m working on a plugin that takes images and offers them on an endpoint to another service.

The service only cares for the latest image so I want to delete the previous image as soon as the new one is taken (just so I don’t run out of space on the camera).

I’ve tried using the project on github.com/ricohapi/theta-plugin-sdk as a base. There, on the callback triggered after taking a photo, I do the following:

HttpConnector camera = new HttpConnector("127.0.0.1:8080");
camera.deleteFile(fileUrl, new HttpEventListener() { ... });

However, the onError function keeps getting called and the file remains. Is there anything I’m doing wrong?

fileUrl looks like this: “http://127.0.0.1:8080/files/aVeryLongCode/100RICOH/R0010042.JPG

1 Like

You may need to check the camera status to make sure the camera is finished taking the picture and saving it to storage. If the camera is not finished, you will get an error. You can test this by putting a 4 second delay between the time the picture was taken and when you delete it. In actual use, you will need to check the camera status. As you are trying to take pictures at less than 1000ms, you likely need to delete all the files at set intervals instead of after every picture as it will take time to delete the file.

There are a large number of code examples at the link below.

https://community.theta360.guide/c/theta-api-usage/plugin/26

You may want to consider using theta4j for some API calls as it is easier to use. Though, it is entirely up to you.

Thanks for your replies.

Seeing that taking a high volume of images might cause problems, I decided to use streams instead.

However, now I find a new problem, and that is that when I try to obtain the live preview

InputStream stream = camera.getLivePreview();
Bitmap bitmap = BitmapFactory.decodeStream(stream);

My bitmap is null. Do you happen to know what might be causing and how to solve it?

Also, on a side note, I tried implementing the library you linked (theta4j) but gradle complains about it not existing.

repositories {
    ...
    jcenter()
}

dependencies {
    implementation 'org.theta4j:theta-web-api:1.5.0' // Gradle says this doesnt exists
}
1 Like

I haven’t developed a plug-in in a while and my knowledge is out of date. When I used theta4j, I built two minimal examples. I’m not sure if they still work.

https://github.com/codetricity/theta4j-minimal-example - there are 5 branches to this to show a single point per branch

https://github.com/codetricity/theta4j-fisheye - concept to show stitching control. Unfortunately, does not appear to reduce the time taken per shot.

There are a number of examples for MotionJPEG.

Note that there is another example use of pushing the MotionJPEG from the plug-in to an Arduino. This is likely not a relevant, but cool.

BTW, if this is a commercial project with potential sales potential for RICOH, please send a note to @jcasman as we can try and get more help from RICOH. This forum receives sponsorship from RICOH and we like to report back on activities. You can either send a direct message through the forum or send an email.

No problem if this is a research or hobby project. We can continue to support your project in this community forum.