MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / LoadStabilizedData

Method LoadStabilizedData

src/effects/Stabilizer.cpp:106–152  ·  view source on GitHub ↗

Load protobuf data file

Source from the content-addressed store, hash-verified

104
105// Load protobuf data file
106bool Stabilizer::LoadStabilizedData(std::string inputFilePath){
107 using std::ios;
108 // Create stabilization message
109 pb_stabilize::Stabilization stabilizationMessage;
110
111 // Read the existing tracker message.
112 std::fstream input(inputFilePath, ios::in | ios::binary);
113 if (!stabilizationMessage.ParseFromIstream(&input)) {
114 std::cerr << "Failed to parse protobuf message." << std::endl;
115 return false;
116 }
117
118 // Make sure the data maps are empty
119 transformationData.clear();
120 trajectoryData.clear();
121
122 // Iterate over all frames of the saved message and assign to the data maps
123 for (size_t i = 0; i < stabilizationMessage.frame_size(); i++) {
124
125 // Create stabilization message
126 const pb_stabilize::Frame& pbFrameData = stabilizationMessage.frame(i);
127
128 // Load frame number
129 size_t id = pbFrameData.id();
130
131 // Load camera trajectory data
132 float x = pbFrameData.x();
133 float y = pbFrameData.y();
134 float a = pbFrameData.a();
135
136 // Assign data to trajectory map
137 trajectoryData[i] = EffectCamTrajectory(x,y,a);
138
139 // Load transformation data
140 float dx = pbFrameData.dx();
141 float dy = pbFrameData.dy();
142 float da = pbFrameData.da();
143
144 // Assing data to transformation map
145 transformationData[id] = EffectTransformParam(dx,dy,da);
146 }
147
148 // Delete all global objects allocated by libprotobuf.
149 google::protobuf::ShutdownProtobufLibrary();
150
151 return true;
152}
153
154
155

Callers

nothing calls this directly

Calls 3

EffectCamTrajectoryClass · 0.85
clearMethod · 0.45

Tested by

no test coverage detected