Skip to content

Commit 9c10bc7

Browse files
committed
sophus2: image proto + some API updates
1 parent 2790a5e commit 9c10bc7

File tree

29 files changed

+88
-68
lines changed

29 files changed

+88
-68
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
with:
6868
path: ${{runner.workspace}}/Pangolin/Sophus
6969
repository: 'strasdat/Sophus'
70-
ref: 5cb40f05e84ab5b8cc05ff1e1ae080bc9b61bed2
70+
ref: a4070695b4bca492647a7966e4cb50f90a44ec95
7171

7272
- name: Checkout Pangolin
7373
uses: actions/checkout@v2

components/pango_context/src/context.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,8 @@ struct ContextImpl : public Context {
430430
const auto maybe_gl_pixel_type = glTypeInfo(pixel_type);
431431
const GlFormatInfo gl_pixel_type = SOPHUS_UNWRAP(maybe_gl_pixel_type);
432432

433-
IntensityImage<> image(ImageSize(imsize[0], imsize[1]), pixel_type);
433+
auto image = IntensityImage<>::fromFormat(
434+
ImageSize(imsize[0], imsize[1]), pixel_type);
434435

435436
glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
436437
glDrawBuffer(GL_FRONT);

components/pango_context/src/gl_drawable/gl_drawn_image.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct GlDrawnImage : public DrawnImage {
3535
if (color_transform) {
3636
u_color_transform = color_transform->cast<float>();
3737
} else if (
38-
image->pixelFormat().num_channels == 1 &&
38+
image->pixelFormat().num_components == 1 &&
3939
u_colormap_index.getValue() == Palette::none) {
4040
u_color_transform =
4141
(Eigen::Matrix4f() << 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1)

components/pango_context/src/gl_drawable/gl_drawn_primitives.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ struct GlDrawnPrimitives : public DrawnPrimitives {
201201

202202
for (int i = 0; i < 4; ++i) {
203203
vao.addVertexAttrib(
204-
location_vertex + i, *vertices, i * data_type.bytesPerPixel());
204+
location_vertex + i, *vertices, i * data_type.numBytesPerPixel());
205205
}
206206

207207
PANGO_GL(glDrawArrays(GL_POINTS, 0, vertices->size() - 3));

components/pango_image/src/image_io_jpg.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ IntensityImage<> LoadJpg(std::istream& is)
191191
// resize storage if necessary
192192
PixelFormat fmt =
193193
PixelFormatFromString(cinfo.output_components == 3 ? "RGB24" : "GRAY8");
194-
image = sophus::IntensityImage<>(
194+
image = sophus::IntensityImage<>::fromFormat(
195195
ImageSize(cinfo.output_width, cinfo.output_height), fmt);
196196
JSAMPARRAY imageBuffer = (*cinfo.mem->alloc_sarray)(
197197
(j_common_ptr)&cinfo, JPOOL_IMAGE,
@@ -289,7 +289,7 @@ void SaveJpg(const IntensityImage<>& img, std::ostream& os, float quality)
289289
if (img.numChannels() != 1 && img.numChannels() != 3) {
290290
throw std::runtime_error("Unsupported number of image channels.");
291291
}
292-
if (img.numBytesPerPixelChannel() != 1) {
292+
if (img.pixelFormat().num_bytes_per_component != 1) {
293293
throw std::runtime_error("Unsupported image depth.");
294294
}
295295

components/pango_image/src/image_io_lz4.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ IntensityImage<> LoadLz4(std::istream& in)
8080
lz4_image_header header;
8181
in.read((char*)&header, sizeof(header));
8282

83-
IntensityImage<> img(
83+
auto img = IntensityImage<>::fromFormat(
8484
ImageSize(header.w, header.h), PixelFormatFromString(header.fmt));
85+
8586
std::unique_ptr<char[]> input_buffer(new char[header.compressed_size]);
8687

8788
in.read(input_buffer.get(), header.compressed_size);

components/pango_image/src/image_io_packed12bit.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct packed12bit_image_header {
1919

2020
void SavePacked12bit(const IntensityImage<>& image, std::ostream& out)
2121
{
22-
if (image.numBytesPerPixelChannel() != 2) {
22+
if (image.pixelFormat().num_bytes_per_component != 2) {
2323
throw std::runtime_error(
2424
"packed12bit currently only supported with 16bit input image");
2525
}
@@ -62,10 +62,10 @@ IntensityImage<> LoadPacked12bit(std::istream& in)
6262
packed12bit_image_header header;
6363
in.read((char*)&header, sizeof(header));
6464

65-
IntensityImage<> img(
65+
auto img = IntensityImage<>::fromFormat(
6666
sophus::ImageSize(header.w, header.h), PixelFormatFromString(header.fmt));
6767

68-
if (img.numBytesPerPixelChannel() != 2) {
68+
if (img.pixelFormat().num_bytes_per_component != 2) {
6969
throw std::runtime_error(
7070
"packed12bit currently only supported with 16bit input image");
7171
}

components/pango_image/src/image_io_png.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ IntensityImage<> LoadPng(std::istream& source)
136136

137137
auto shape = sophus::ImageLayout::makeFromSizeAndPitch<uint8_t>(
138138
sophus::ImageSize(w, h), pitch);
139-
IntensityImage<> img(shape, PngFormat(png_ptr, info_ptr));
139+
auto img = IntensityImage<>::fromFormat(shape, PngFormat(png_ptr, info_ptr));
140140

141141
png_bytepp rows = png_get_rows(png_ptr, info_ptr);
142142
for (unsigned int r = 0; r < h; r++) {
@@ -191,7 +191,7 @@ void SavePng(
191191
png_ptr, (png_voidp)&stream, pango_png_stream_write,
192192
pango_png_stream_write_flush);
193193

194-
const int bit_depth = image.numBytesPerPixelChannel() * 8;
194+
const int bit_depth = image.pixelFormat().num_bytes_per_component * 8;
195195

196196
int colour_type;
197197
switch (image.numChannels()) {

components/pango_image/src/image_io_ppm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ IntensityImage<> LoadPpm(std::istream& in)
4848
in.ignore(1, '\n');
4949

5050
if (!in.fail() && w > 0 && h > 0) {
51-
IntensityImage<> img(
51+
auto img = IntensityImage<>::fromFormat(
5252
sophus::ImageSize(w, h), PpmFormat(ppm_type, num_colors));
5353

5454
// Read in data

components/pango_image/src/image_io_raw.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ IntensityImage<> LoadImageNonPlanar(
1414
{
1515
ImageLayout shape = ImageLayout::makeFromSizeAndPitch<uint8_t>(
1616
ImageSize(raw_width, raw_height), raw_pitch);
17-
IntensityImage<> img(shape, raw_fmt);
17+
auto img = IntensityImage<>::fromFormat(shape, raw_fmt);
1818

1919
// Read from file, row at a time.
2020
std::ifstream bFile(filename.c_str(), std::ios::in | std::ios::binary);
@@ -33,11 +33,11 @@ template <typename Tin, typename Tout>
3333
IntensityImage<> ToNonPlanarT(const IntensityImageView& planar_image)
3434
{
3535
PixelFormat new_fmt = PixelFormat::fromTemplate<Tout>();
36-
const size_t planes = new_fmt.num_channels;
36+
const size_t planes = new_fmt.num_components;
3737

3838
PANGO_ENSURE(planar_image.height() % planes == 0);
3939
PANGO_ENSURE(sizeof(Tin) * planes == sizeof(Tout));
40-
PANGO_ENSURE(sizeof(Tout) == new_fmt.bytesPerPixel());
40+
PANGO_ENSURE(sizeof(Tout) == new_fmt.numBytesPerPixel());
4141

4242
ImageView<Tin> in = planar_image.imageView<Tin>();
4343
MutImage<Tout> out(

0 commit comments

Comments
 (0)