A team of four will develop a service that allows you to check the current location of buses and the congestion status on the Web by analyzing the location information of buses circulating on campus and images inside the campus in a university independent study. became. The development of the whole team has settled down, and I posted it with the intention of summarizing the areas I was in charge of.
It may be difficult to understand because it focuses on the content that I was in charge of. I would be very grateful if you could report any points that are difficult to understand ** or points that should be corrected **.
Please refer to the material posted on slideshare for the contents of other personnel. Try developing a university circulation bus system as a team. The source code is on GitHub.
With this system I was in charge of developing the bus client. The role of the bus client is to measure the location information and congestion status of the bus. Sending the image on the bus to the API server. This is the role of the bus client in the entire system.
A bus client is realized by developing an Android application with the following three functions and installing an Android terminal on which the application is installed in the bus.
The contents of JSON data (left: location information, right: image information).
--Integrated development environment: Android Studio --Language used: Java --Android device used: VAIO Phone A VPA0511S
tamabus ├ AndroidManifest.xml ├ MainActivity.java ├ UploadTask.java ├ activity_main.xml ├ colors.xml ├ strings.xml └ styles.xml
--AndroidManifest.xml: A file that describes the permissions to use --MainActivity.java: The program described here works. --UploadTask.java: Asynchronous communication processing class when posting data to the server --activity_main.xml: File that describes the layout of the application screen --colors.xml, strings.xml, styles.xml: Files that contain information such as colors, character strings, and formats used in the app.
The following is the screen of the app. The camera is always activated and it continues to be projected on the TextureView object, which is an Android GUI component. Below the TextureView object, blue letters represent latitude and red letters represent longitude. Below the latitude and longitude, the elapsed time since the app was launched is shown. The elapsed time is updated every 10 seconds, and when the elapsed time is updated, it can be seen that the position information and the image information have been transmitted.
The flow after launching the app is as follows. After initializing the variables, etc., check whether the location information authority and camera use authority are permitted. If both permissions are allowed, the flow from "Get location information from GPS" to "Post encoded image" is looped every 10 seconds.
At the beginning of development, I thought that automatic shooting with a camera could use the Intent class function of Android Studio to call a genuine camera app and shoot automatically with the launched camera app. However, it turns out that the genuine camera app can't take pictures unless someone presses the shutter, and it can't take pictures automatically. How to get the image in the bus was the biggest issue at the beginning of development.
The image taken on the bus client side is encoded with Base64, and the image data converted into a character string is sent to localhost in the test. The receiving side succeeded in receiving the character string of the image data, but could not decode the character string.
I was looking for information on how to get an image other than launching the genuine camera app and pressing the shutter to shoot, but I couldn't find it. So I thought that I could find it if I searched for information in English, and when I searched for information in English, I captured what was in the camera into the TextureView object of the GUI component, and captured the image that was transferred to the TextureView object in a certain period of time. I found a method called, and I was able to solve the problem with this method.
If I decoded it on the Android side before sending the encoded character string, it could be decoded correctly, so I guessed that Post might be the cause. After investigating, I found that the + symbol in the posted character string was replaced with a half-width space. I sent the data to localhost in the test. The red line below is the part converted to a half-width space.
The problem was solved by creating a program that replaces the half-width space included in the character string received on the server side with the + symbol.
We built an environment on localhost to display JSON data of location information and image information received by XAMPP. You can see that the data can be sent correctly.
The bus client that I am in charge of has been completed, so I plan to help with image analysis that analyzes the degree of congestion from the transmitted images. I would like to adjust the schedule with the members, resume development, and bring it to operation.
Recommended Posts