Giter VIP home page Giter VIP logo

Comments (8)

DavidGillsjo avatar DavidGillsjo commented on May 31, 2024 1

Yes, you would need to add functionality in IMUManager.java, RecordingWriter.java and extend the protobuf specification in recording.proto.

I've planned on adding this functionality but unfortunately don't have the time and don't need it in my current project.
So you are most welcome to make a pull request if you implement it.

from videoimucapture-android.

DavidGillsjo avatar DavidGillsjo commented on May 31, 2024

Hi,
Sorry for the late reply.

Yes, that part would benefit from some better documentation.
I have some examples on how to read the data in the calibration folder.
For example data2statistics.py reads a protobuf from python.

You have to use protoc to compile a python module to read the protobuf file.
For the compiling of the python package there is an example in the calibration docker file.

You would do something like this

#Install protoc
wget -nv "https://github.com/protocolbuffers/protobuf/releases/download/v3.13.0/protoc-3.13.0-linux-x86_64.zip" -O protoc.zip &&\  
sudo unzip protoc.zip -d /usr/local &&\
rm protoc.zip

#Build module
mkdir proto_python 
protoc --python_out=proto_python protobuf/recording.proto
export PYTHONPATH="/proto_python:${PYTHONPATH}"

# Other Python dependencies
pip3 install protobuf pyquaternion

#Run script
python3 calibration/data2statistics.py data/2021_06_24_14_30_19/video_meta.pb3

from videoimucapture-android.

Frikster avatar Frikster commented on May 31, 2024

Following the new instructions get me to this error message on the last step:

python3 calibration/data2statistics.py data/video_meta.pb3 
Traceback (most recent call last):
  File "calibration/data2statistics.py", line 3, in <module>
    from recording_pb2 import VideoCaptureData
ModuleNotFoundError: No module named 'recording_pb2'

I am guessing all recording.proto always refers to this file. The instructions don't make it explicit so I add a step of cloning the repo and running commands from the root. I also create a data folder and add the recordings from my phone in here.

Ultimately I managed to get an output by changing from recording_pb2 import VideoCaptureData to from protobuf.test_proto.recording_pb2 import VideoCaptureData and then within a clean venv the only dependencies it looks like I needed to install via pip are numpy, matplotlib, protobuf and google. The output isn't that clean though and I see this as an error message:

/Downloads/VideoIMUCapture-Android$ python calibration/data2statistics.py data/2021_06_24_14_30_19/video_meta.pb3
intrinsic_params: 993.1973266601562
intrinsic_params: 993.1973266601562
intrinsic_params: 478.9999694824219
intrinsic_params: 640.0
intrinsic_params: 0.0
focus_calibration: APPROXIMATE
timestamp_source: REALTIME
lens_pose_rotation: 0.0
lens_pose_rotation: 0.0
lens_pose_rotation: 0.0
lens_pose_rotation: 1.0
lens_pose_translation: 0.0
lens_pose_translation: 0.0
lens_pose_translation: 0.0

gyro_info: "{Sensor name=\"LSM6DSR Gyroscope-Uncalibrated\", vendor=\"STMicro\", version=142855, type=16, maxRange=34.90549, resolution=0.0012216945, power=0.55, minDelay=2404}"
gyro_resolution: 0.0012216945178806782
accel_info: "{Sensor name=\"LSM6DSR Accelerometer-Uncalibrated\", vendor=\"STMicro\", version=142855, type=35, maxRange=156.90636, resolution=0.0047856453, power=0.17, minDelay=2404}"
accel_resolution: 0.004785645287483931

Traceback (most recent call last):
  File "calibration/data2statistics.py", line 172, in <module>
    stats(proto, result_dir, show = not args.hide_plot)
  File "calibration/data2statistics.py", line 16, in stats
    camera_stats(proto, result_path)
  File "calibration/data2statistics.py", line 43, in camera_stats
    stat_list.append(getattr(frame_data, stat))
AttributeError: focus_locked

Is this a problem or is it done? Because doing something like this to read it into a pandas df is not working:

import proto_python.protobuf.recording_pb2 as recording_pb2                     # compiled protobuf message module
from read_protobuf import read_protobuf # https://github.com/mlshapiro/read-protobuf

MessageType = recording_pb2.MessageType()        # instantiate a new message type -> AttributeError: module 'proto_python.protobuf.recording_pb2' has no attribute 'MessageType'
df = read_protobuf('demo.pb', MessageType)    # use file instead of bytes

As a sidenote,

Trying with docker, I can run ./build_docker.sh and ./run_docker.sh but a quick try to run data2statistics.py within the container leads to:

python3 calibration/data2statistics.py data/2021_06_24_14_30_19/video_meta.pb3
Traceback (most recent call last):
  File "calibration/data2statistics.py", line 3, in <module>
    from recording_pb2 import VideoCaptureData
  File "/proto_python/recording_pb2.py", line 5, in <module>
    from google.protobuf import descriptor as _descriptor
ImportError: No module named 'google'

installing via pip install google (which succeeds within the container) does not resolve the issue. As per this SO answer I also tried pip install --upgrade google-api-python-client which leads to:

ERROR: Cannot uninstall 'pyasn1-modules'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

This being inside the container I am not sure what to make of it.

from videoimucapture-android.

Frikster avatar Frikster commented on May 31, 2024

@DavidGillsjo It is perhaps also worth highlighting my use case:

I'm looking to have Android recordings from a ship and detect other ships in the water, their position, velocity etc relative to the moving ship I am on. But right now as a pure POC to find a library I just want to be able to have any arbitrary video recording with synchronised ICU data. This app seems to do the latter but I just cannot read the pb3 file easily.

Am I perhaps looking at the wrong project for my use case?

from videoimucapture-android.

DavidGillsjo avatar DavidGillsjo commented on May 31, 2024

Hi again,

Thanks for using the app and providing feedback, it will certainly help the project.
Though I'm sorry you are facing trouble with the protobuf file.

My proposed command sequence should be executed in the root of the git repo, sorry for not stating that.
I also see that I made a mistake on the environment variable, so that it probably why python cannot find it.
It is probably just easier to place recording_pb2.py in your own project.
Revised instructions:

#Go to git repo
cd <some_path>/VideoIMUCapture-Android

#Install protoc
wget -nv "https://github.com/protocolbuffers/protobuf/releases/download/v3.13.0/protoc-3.13.0-linux-x86_64.zip" -O protoc.zip &&\  
sudo unzip protoc.zip -d /usr/local &&\
rm protoc.zip

# Build module - Alternative  1
# Add to pythonpath
mkdir proto_python 
protoc --python_out=proto_python protobuf/recording.proto
export PYTHONPATH="$(pwd)/proto_python:${PYTHONPATH}"

# Build module - Alternative  2
# Just place the parser in your own project.
protoc --python_out=<your_project_dir> protobuf/recording.proto

# Other Python dependencies
pip3 install protobuf pyquaternion

#Run script
python3 calibration/data2statistics.py data/2021_06_24_14_30_19/video_meta.pb3

The protobuf parser protobuf.test_proto.recording_pb2 is older and I should remove that from the repo.
I am considering keeping an up to date version, but I cannot really keep generated readers for all coding languages in the repo, so I think protobuf/recording.proto is enough. That is most likely why you get the error.

I'm not familiar with [https://github.com/mlshapiro/read-protobuf] but I suspect that MessageType in your case would be VideoCaptureData? I'm not sure how is handles nested structures though. This might work:

from recording_pb2 import VideoCaptureData   # compiled protobuf message module
from read_protobuf import read_protobuf # https://github.com/mlshapiro/read-protobuf

# Read proto
df = read_protobuf('data/2021_06_24_14_30_19/video_meta.pb3', VideoCaptureData())    # use file instead of bytes

When it comes to issues with the container I also ran in to this recently. I had to uninstall google which is not the correct package and install google-cloud. Will update documentation and Dockerfile when I've looked into it a bit more. More exactly I did

pip uninstall google
pip install google-cloud protobuf

For your use case it might very well be a good match. If you want GPS positions I have not implemented this and you would need to add this functionality to the Android app.

from videoimucapture-android.

Frikster avatar Frikster commented on May 31, 2024

I am unfortunately still running into the same error as before:

python3 calibration/data2statistics.py data/2021_06_24_14_30_19/video_meta.pb3
Traceback (most recent call last):
  File "calibration/data2statistics.py", line 3, in <module>
    from recording_pb2 import VideoCaptureData
ModuleNotFoundError: No module named 'recording_pb2'

from videoimucapture-android.

DavidGillsjo avatar DavidGillsjo commented on May 31, 2024

OK, so when you are running

protoc --python_out=<your_project_dir> protobuf/recording.proto

where does your recording_pb2.py end up?
If you find it and place it in the folder calibration, so that it shares folder with data2statistics.py, it should work.

If that works then it is just a matter of making recording_pb2.py visible to python. In short you can either

  1. Place it in your own project
  2. Add it to PYTHONPATH as a setup-step for your project
  3. Install it systemwide using distutils or manually with copy and permissions adjustment.

from videoimucapture-android.

Frikster avatar Frikster commented on May 31, 2024

Awesome, that works, thanx!

image

If I wanted to add GPS stats, would you recommend I make code changes in data2statistics.py? GPS tracking is a hard requirement for my project unfortunately. Perhaps the easiest would be to make changes in IMUManager.java? Thanx in advance.

from videoimucapture-android.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.