 Okay, continuing with our series on accessing cameras through USB and networking. Last week we were looking at the Ricoh Theta camera, and again we're going to be looking at it this week. Last week we looked at using GPhoto 2, which is a great little command line application. This week we're going to quickly look, very quickly look at a Python script that works with this camera and a GUI front end I made for it. On the shell I'm running here, although this can be done on your desktop as well, same exact thing because I'm running Debian here, but this is Debian running on my phone. I have a Moto G with Debian and a churroot within Android, so I can have this back end running in Debian and then use the web GUI that I've created here in the Android front end. So I've gone over this sort of thing a lot in the past, so let's go ahead and just get started. In my root directory here I've created a directory called www, which is empty, and if I open up my web browser here, if you go to github.com forward slash metalx1000, that's my user account, and go to the repositories and search for Ricoh or Theta or 360, 360 might bring up a few other things, you'll come up with this. But here's the URL I'll try to remember putting in the description of this video. I am going to want to copy this project to my phone. So right now my phone is connected to my local Wi-Fi. I'm going to right click here and say copy link address and then go back to my shell here, which again, don't want you to forget, is on my phone, although you can do this on your desktop. The reason I'm doing it on my phone is one, just because that's why I've designed this interface for, and two, once I connect to the Ricoh, Theta, I no longer have internet access, so if I need to look something up or bring something up on my computer here while doing the tutorial, I'd have to disconnect from the phone. Here I can already connect to it. But right now my phone is connected to my router. I can paste in that URL that you get. So I'm pulling down the zip file of the project I've created here. Once it's downloaded, I can unzip it. I don't have unzip installed. I do have busybox installed. It's a very useful tool. In fact, we're going to use it in this project for other parts, but it has unzipped built-in, so I can unzip that. So now I can list out, you can see we have the zip file we downloaded and the folder that we extracted from it, so I can move into that folder. So you can see that I am in my WWW Ricoh, Theta 360 WebUI master folder. So here I can now list out the files that are in here. License, I wrote this under a GPL version three license. The read me will talk a little bit about the project. We have our basic WebUI, which is the part I've created. The lib files are just I used bootstrap and jQuery. And since once you're connected to the Ricoh Theta, you won't have internet. I couldn't link to them online, so I downloaded them to this folder so they're running locally on the phone. And then in the CGI bin, I have a few scripts, but only one that I'm actually using two of them have GPhoto 2 commands in them. But the third, which I actually use, which I call Theta PY is a Python script. There's a link to it in this project, the project I got it from. But it's a script that basically it's pure Python used to access the camera. The same way we did with GPhoto 2 using the PTPIP protocol. And the only things I really changed, if you go up to the very top, since I'm going to be running this as a server side script, I added in these two lines because you need to give a content type and then a blank line after that for a server side script using the web server we're using. And then if you go all the way down to the very end, where the main functions are called, there's a function that's used here to initiate capture. And then there's here where it downloads the image to the phone, which was very iffy, sometimes works, sometimes didn't. And even when it did work, it took forever, which means if you took a picture, you'd have to wait 10 seconds for this to time out before you could take another picture, which was kind of long. So I just commented it out, you can always remove those comment marks and try it out. And then it closes the connection here at the end. So you can look over that script yourself. Again, it's in my copy of it's in my project. I also linked to the original project I got from my main portion of this is a very, very simple HTML file again at the top here. I'm loading up jQuery and Bootstrap. I set it to a mobile view here, basically to set scaling. And we'll scroll down to the main elements before we look at the script, but it has basically a title here, a header, and then a couple of buttons. And button one is labeled ID snapshot. The other ones here don't have IDs, but they have a class of delay shot. And they also have a count attribute that I gave, which is three, five, 10 and 30. As I said, the original camera doesn't have a delayed timer for taking pictures. You can have it set where it takes pictures in intervals, but not just a regular delayed timer and you need their application, their app for your phone to even implement that simple functionality. So up here, sorry, this isn't color coded again. I'm running on my phone, so I don't have Vim set up like I normally do. But here we're saying, OK, find the elements of the button with the ID of snapshot. And then we're just going to call that Python script. So again, that's how simple it is to make a GUI interface in HTML for Python or really any language you want. Here, it's returning whatever output that command gives, and it actually puts it in a message field down here at the bottom, a message div tag. I have that there for troubleshooting. You can remove that if you want. And then here's the same, basically the same function here, but we're saying a set timeout delay. And what it does is here is when one of the delay shot buttons is pressed, it looks at that and it says, OK, this element, the attribute of count, which is an attribute I made up, take that, set the delay to that and then multiply it by a thousand because set timeout is by thousands of a second. So in this example, I use three, five, ten and thirty seconds. So if we just put three in here to be three thousandth of a second, they say that, right? Doesn't matter, multiply it by a thousand and you get three seconds. So that's what happens here. So before we actually see this running on the phone, let me go to my desktop here where I've also downloaded this project. So right here, I could run this on my desktop and I'd be good to go. And I have these buttons. I can click them once, once I connected to the theta through Wi-Fi and it will run these commands, but I want to run it on my phone. So let's go ahead and do that now. OK, so remember, we're in the folder that the project is in. The Python script is in a CGI dash bin folder. If you download the project, it's already set up like that. I have a busy box installed, busy box and I'm going to run the HTTPD. And I am going to say port nine thousand just to make sure I use a port that's not being used. Go ahead and run that. And now I have a web server running on that port. Now, at this point, I am going to connect to the theta. So let me go ahead and turn on my camera here to record this. So here's the theta. I'm going to turn the power on. The red light lights up here for Wi-Fi. You can't really see that. But now on my phone, I can type in my passcode here. OK, the theta shows up. I will connect to it. Sometimes I have to try connecting to it a few times for it to work. I know this isn't the best shot here. OK, I'm connected to it. So now I can open up this and I can say one to seven dot zero dot zero dot one port 90. Also, the command I ran runs that everywhere. You can work, you can run it so it only runs on a loop back, which would be a little more secure. But right now I'm hooked to the camera and nothing else is on the camera's network. OK, so here are the buttons. And so now I can and you can listen to the camera. There we go. So I press take a photo and it took a photo. Now I can hit this button and now we'll wait three seconds and then take the photo. And so forth and so on. We get a little text out here at the bottom again. That's for troubleshooting. I know this isn't the best picture here. I can do take photo delay five. Now again, I'm running this directly on my phone here, which is connected to the camera. It would have been ideal and great. And I don't know why companies don't do this more often. Just put the web interface on there. They could have wrote something like this. You saw how simple it was. Wouldn't even need the back end that I had because it's already on the camera. And when I connect to the camera, it just redirects my web browser to the camera interface. But no, they want you to install some crappy app, which now you don't have to. So the button I just pressed there is a 10 second delay. So we'll wait 10 seconds and then 10 seconds. There we go. So that's it. So now I don't I don't really need their app anymore. In fact, I have the functionality I wanted, which is delay timer, which they don't even have in the actual app for the camera. And I don't need their proprietary software. On my phone, it's I already just have a few simple scripts running. So that is it. I hope you enjoyed this tutorial. Even if you don't have a theta camera, I hope you learned something fairly somewhat advanced a little bit here. But I've got over all this stuff in previous tutorials about using busybox, HTTPD. And once you have that up and running, again, it's running as whatever you're running on. And since I'm running in a chur route, I'm running as route already inside that chur route. So full functionality, although you shouldn't need route permissions to to use to connect to this device to that camera. So now I'm mumbling a little bit. So I'm going to just say thank you for watching. Again, I hope that this tutorial is educational for you. Useful if you have the camera, if not, might be useful for other devices. Overall, I hope you learned something, even if it's not directly for this project. But maybe you can use some of the stuff in a similar project. If you did like it, be sure to like, subscribe, comment. Visit my website, filmsbychrist.com. That's Chris Decay. There's a link to the description. Try to remember, put a link to the GitHub project. Again, once you download it, you just have to run busybox in that folder and you're good to go. Whether it's laptop, desktop, tablet or phone. As long as you're running Linux, you could you should be able to install busybox on there and get this up and going. Again, the back end script I'm using here is Python. So you will need Python installed on whatever you're doing, which is easy in most cases. One of the reasons I went with that rather than the GPhoto 2 is GPhoto 2, you still could run that on most things, but I haven't done it other than in a true route. Anyway, thanks for watching and I hope that you have a great day. Okay, this is an introduction to filmsbychrist.com. I'm Chris. That's Chris Decay. That's me right there. My daughter, Amber. And my wife, Jennifer. We pretty much live in the swamps of Florida. I'm a firefighter by day as well as by night. We work long hours, but that's not why you're here. You're here about the videos I put up on YouTube. These videos are mainly about computers and programming, which means most of my videos look something like this. And if that's what you're interested in, great. If not, that's all right. I do videos on other topics too, such as video editing, special effects, photo editing, 3D design, and music creation. If you are one of my viewers and you enjoy my videos, my Patreon page is a place where you can go to help support my videos. So I ask that you take the time to go to my Patreon page and look at different levels of rewards you can receive for different levels of backing. There should be a link in the description of this video if you're watching it on YouTube. Otherwise, you can visit patreon.com forward slash metalx1000. And I thank you for your time and your support. Have a great day.