Store descriptor coefficients in 1 byte instead of 4
Change-Id: I26ed08a552a4452de13ed8508c3c00d68d590152
diff --git a/y2020/vision/sift/demo_sift_training.py b/y2020/vision/sift/demo_sift_training.py
index 3fa33cf..c78a44a 100644
--- a/y2020/vision/sift/demo_sift_training.py
+++ b/y2020/vision/sift/demo_sift_training.py
@@ -26,7 +26,8 @@
for keypoint, descriptor in zip(keypoints, descriptors):
Feature.FeatureStartDescriptorVector(fbb, len(descriptor))
for n in reversed(descriptor):
- fbb.PrependFloat32(n)
+ assert n == round(n)
+ fbb.PrependUint8(int(round(n)))
descriptor_vector = fbb.EndVector(len(descriptor))
Feature.FeatureStart(fbb)
diff --git a/y2020/vision/sift/sift.fbs b/y2020/vision/sift/sift.fbs
index 3e2daaf..24fd64d 100644
--- a/y2020/vision/sift/sift.fbs
+++ b/y2020/vision/sift/sift.fbs
@@ -9,7 +9,8 @@
// Represents a single feature extracted from an image.
table Feature {
- // Contains the descriptor data.
+ // Contains the descriptor data. OpenCV likes to represent them as floats, but
+ // they're really ubytes.
//
// TODO(Brian): These are scaled to be convertible to chars. Should we do
// that to minimize storage space? Or maybe int16?
@@ -17,7 +18,7 @@
// The size of this depends on the parameters. It is width*width*hist_bins.
// Currently we have width=4 and hist_bins=8, which results in a size of
// 4*4*8=128.
- descriptor:[float];
+ descriptor:[ubyte];
// Location of the keypoint.
x:float;