yossato / virtualGimbal

virtualGimbal is an electronic stabilize device for videos that were taken by hand held camera. (I.e. DSLR)
162 stars 29 forks source link

Formula to calculate angular_velocity_rad_per_sec #13

Open attilafustos opened 3 years ago

attilafustos commented 3 years ago

I am not sure how to calculate properly the gyro values stored in the json file. I seen a formula in the code but I am not sure about it: 1.f/16.4f*M_PI/180.0f The values I get from the flight controller seem to be in the -128 to 128 range. Thank you.

yossato commented 3 years ago

@attilafustos The formula is for MPU9250 gyro sensor. IMG_8456
Your flight controller has 8bit accuracy, it is not enough accurate for video stabilization.

attilafustos commented 3 years ago

@yossato Thank you for your reply. BetaFlight compatible flight controllers use STM32 processor.

attilafustos commented 3 years ago

@yossato So if I understand correctly, Gyro Raw / 16.4 gives me rotation in angles/sec. From this I have to convert radian_per_sec = angle_per_sec * (PI/180) ? 1° × π/180 = 0.01745rad

wenzhicode commented 3 years ago

Yes, you are right @attilafustos

I tried stabilizing the Gopro video, which I put on my flight control, but it hasn't worked so far

attilafustos commented 3 years ago

@wenzhicode Did you encounter an error or just no stabilization on the resulting video?

wenzhicode commented 3 years ago

I encountered an error .

Here are my steps:

  1. Shooting Chesspattern videos with GoPro to get calibration parameters
  2. Shoot a flight video with GoPro and separate the gyroscope data from the flight video, blackbox2gpmf
  3. Get the predicted angular velocity data from the flight video
  4. Select the placement mode of the gyroscope as 12, gpmf
  5. Use the data and videos obtained above to increase stability
  6. Get an exception thrown

I think the steps are correct, but the separated data or video format is wrong.

attilafustos commented 3 years ago

@wenzhicode To get the gyro data from the flight controller I made my own app. You need to store the data as a json file, scaled to radian/sec. Also you need to set the sampling rate on json to sampling rate used to get gyro data. I set it to 1000 hz. The exception I got from the stabilizer is assertion error. I have another issue open where I posted a screenshot.

fgiudice98 commented 3 years ago

Hi all. I just stumbled across this repo doing research for making a tool just like this for my quadcopter using gyro data from blackbox, but seems i'm not the only one that had the same idea. BTW @yossato brilliant idea! I like the concept of this project a lot! Good job! @attilafustos do you think you can share the tool to convert from blackbox to json? Maybe a github repo so we can help eachother?

wenzhicode commented 3 years ago

From the README, the sampling rate of the gyroscope in the gopro video is related to the model, I separated the gyroscope data directly from the video. I guess the separated data does not meet the requirements. Yeah, I'm converting the gyroscope data to radian/ SEC.

I think you can use Python to convert the data in CSV to JSON format, and CSV files can be exported from BBL files. @fgiudice98 blackbox2gpmf You can look at this

fgiudice98 commented 3 years ago

Yeah, i was going to make a thing like that, but since we are basically working on the same thing why not working together?

wenzhicode commented 3 years ago

What can I do?

If Yossato can find time to write some documentation on this, such as what steps to take from start to finish. I mean, let's say we're going to stabilize the flight video, maybe we used different devices, and now we need to extract some common points from it, and then divide the work to implement those common points, I think it's going to be a lot faster.

attilafustos commented 3 years ago

@wenzhicode @fgiudice98 https://github.com/attilafustos/bf2json

fgiudice98 commented 3 years ago

@wenzhicode I think a repo with scripts to adapt and configure for the use with blackbox data along with some preconfigured cameras (such as Hero7, or Caddx integrated) can be a good start

wenzhicode commented 3 years ago

Yes.

As I understand it, virtualGimbal needs to have the following pieces of data:

  1. Calibration parameters of camera
  2. Authentic gyroscope data
  3. Prediction data used to find synchronization points The correct gyroscope data can be extracted from the Blackbox using a script, and the calibration parameters of the camera should not be difficult to obtain.My main challenge is how to verify that a video meets virtualGimbal's requirements, or can we modify virtualGimbal to match our videos?
fgiudice98 commented 3 years ago

@wenzhicode what are the specs of the video you are trying to stabilize?