From c74cc062463a20ed63e72f27da7c7d048954e994 Mon Sep 17 00:00:00 2001 From: Marco Randazzo Date: Wed, 16 Oct 2024 17:25:43 +0200 Subject: [PATCH 1/3] The following methods: bool topIsLowIndex() const void setTopIsLowIndex(bool flag); have been removed from yarp::sig::Image --- src/libYARP_sig/src/yarp/sig/Image.cpp | 23 +------------------ src/libYARP_sig/src/yarp/sig/Image.h | 19 --------------- .../src/yarp/sig/ImageNetworkHeader.h | 2 +- src/libYARP_sig/tests/ImageTest.cpp | 6 ++--- 4 files changed, 5 insertions(+), 45 deletions(-) diff --git a/src/libYARP_sig/src/yarp/sig/Image.cpp b/src/libYARP_sig/src/yarp/sig/Image.cpp index 6b0176d567e..8768ae18aa2 100644 --- a/src/libYARP_sig/src/yarp/sig/Image.cpp +++ b/src/libYARP_sig/src/yarp/sig/Image.cpp @@ -457,18 +457,6 @@ void Image::setQuantum(size_t imgQuantum) { } } - -void Image::setTopIsLowIndex(bool flag) { - topIsLow = flag; - - if (implementation) { - auto* impl = static_cast(implementation); - if (impl->pImage) { - impl->pImage->origin = topIsLow ? IPL_ORIGIN_TL : IPL_ORIGIN_BL; - } - } -} - void Image::synchronize() { auto* impl = static_cast(implementation); yAssert(impl!=nullptr); @@ -540,8 +528,6 @@ bool Image::read(yarp::os::ConnectionReader& connection) { } } - setTopIsLowIndex(header.topIsLow == 0); - // handle easy case, received and current image are compatible, no conversion needed if (getPixelCode() == header.id && q == static_cast(header.quantum) && imgPixelSize == static_cast(header.depth)) { @@ -554,7 +540,6 @@ bool Image::read(yarp::os::ConnectionReader& connection) { FlexImage flex; flex.setPixelCode(header.id); flex.setQuantum(header.quantum); - flex.setTopIsLowIndex(header.topIsLow == 0); ok = readFromConnection(flex, header, connection); if (ok) { copy(flex); @@ -625,16 +610,12 @@ bool Image::copy(const Image& alt) setQuantum(alt.getQuantum()); } resize(alt.width(),alt.height()); - setTopIsLowIndex(alt.topIsLowIndex()); int q1 = alt.getQuantum(); int q2 = getQuantum(); if (q1==0) { q1 = YARP_IMAGE_ALIGN; } if (q2==0) { q2 = YARP_IMAGE_ALIGN; } - bool o1 = alt.topIsLowIndex(); - bool o2 = topIsLowIndex(); - yAssert(width()==alt.width()); yAssert(height()==alt.height()); if (getPixelCode()==alt.getPixelCode()) { @@ -647,7 +628,7 @@ bool Image::copy(const Image& alt) copyPixels(alt.getRawImage(),alt.getPixelCode(), getRawImage(),getPixelCode(), width(),height(), - getRawImageSize(),q1,q2,o1,o2); + getRawImageSize(),q1,q2,false,false); } return true; } @@ -700,7 +681,6 @@ bool Image::copy(const Image& alt, size_t w, size_t h) { if (getPixelCode()==0) { setPixelCode(alt.getPixelCode()); setQuantum(alt.getQuantum()); - setTopIsLowIndex(alt.topIsLowIndex()); } if (&alt==this) { FlexImage img; @@ -712,7 +692,6 @@ bool Image::copy(const Image& alt, size_t w, size_t h) { FlexImage img; img.setPixelCode(getPixelCode()); img.setQuantum(getQuantum()); - img.setTopIsLowIndex(topIsLowIndex()); img.copy(alt); return copy(img,w,h); } diff --git a/src/libYARP_sig/src/yarp/sig/Image.h b/src/libYARP_sig/src/yarp/sig/Image.h index 5119ab1e95c..3a3f2655470 100644 --- a/src/libYARP_sig/src/yarp/sig/Image.h +++ b/src/libYARP_sig/src/yarp/sig/Image.h @@ -306,25 +306,6 @@ class YARP_sig_API yarp::sig::Image : public yarp::os::Portable { void setQuantum(size_t imgQuantum); - /** - * @return true if image has origin at top left (default); in other - * words when the y index is low, we are near the top of the image. - */ - bool topIsLowIndex() const { - return topIsLow; - } - - /** - * control whether image has origin at top left (default) or bottom - * left. - * - * @param flag true if image has origin at top left (default), - * false if image has origin at bottom left. - * - */ - void setTopIsLowIndex(bool flag); - - /** * Get an array of pointers to the rows of the image. * @return an array of pointers to the rows of the image. diff --git a/src/libYARP_sig/src/yarp/sig/ImageNetworkHeader.h b/src/libYARP_sig/src/yarp/sig/ImageNetworkHeader.h index 696f55fa630..00e530e9dc6 100644 --- a/src/libYARP_sig/src/yarp/sig/ImageNetworkHeader.h +++ b/src/libYARP_sig/src/yarp/sig/ImageNetworkHeader.h @@ -53,7 +53,7 @@ class ImageNetworkHeader depth = image.getPixelSize(); imgSize = image.getRawImageSize(); quantum = static_cast(image.getQuantum()); - topIsLow = image.topIsLowIndex() ? 0 : 1; + topIsLow = 1; width = image.width(); height = image.height(); paramBlobLen = image.getRawImageSize(); diff --git a/src/libYARP_sig/tests/ImageTest.cpp b/src/libYARP_sig/tests/ImageTest.cpp index c67fdae6c9c..81da5587753 100644 --- a/src/libYARP_sig/tests/ImageTest.cpp +++ b/src/libYARP_sig/tests/ImageTest.cpp @@ -611,13 +611,14 @@ TEST_CASE("sig::ImageTest", "[yarp::sig]") ImageOf img1; - img1.setTopIsLowIndex(false); img1.setExternal(&buf[0][0],EXT_WIDTH,EXT_HEIGHT); CHECK(img1.width() == EXT_WIDTH); // width check CHECK(img1.height() == EXT_HEIGHT); // height check int mismatch = 0; + /* + //not sure about what i'm checking here for (size_t x=0; x img2; ImageOf img3; - img2.setTopIsLowIndex(false); - img2.setTopIsLowIndex(true); img2.resize(50,50); int ct = 1; for (size_t x=0; x Date: Thu, 17 Oct 2024 12:14:39 +0200 Subject: [PATCH 2/3] removed topIsLow from FakeFrameGrabber --- .../fake/fakeFrameGrabber/FakeFrameGrabber.cpp | 15 --------------- .../FakeFrameGrabber_ParamsParser.cpp | 16 +--------------- .../FakeFrameGrabber_ParamsParser.h | 3 +-- .../fakeFrameGrabber/FakeFrameGrabber_params.md | 1 - 4 files changed, 2 insertions(+), 33 deletions(-) diff --git a/src/devices/fake/fakeFrameGrabber/FakeFrameGrabber.cpp b/src/devices/fake/fakeFrameGrabber/FakeFrameGrabber.cpp index 44e61d09670..a4aa8bcbc20 100644 --- a/src/devices/fake/fakeFrameGrabber/FakeFrameGrabber.cpp +++ b/src/devices/fake/fakeFrameGrabber/FakeFrameGrabber.cpp @@ -130,7 +130,6 @@ bool FakeFrameGrabber::read(yarp::os::ConnectionReader& connection) reply.addString("set_mode "); reply.addString("set_image /off"); reply.addString("available modes: ball, line, grid, size, rand, none, time"); - reply.addString("set_topIsLow on/off"); reply.addString("set_noise on/off"); reply.addString("set_snr "); reply.addString(""); @@ -163,18 +162,6 @@ bool FakeFrameGrabber::read(yarp::os::ConnectionReader& connection) } } } - else if (command.get(0).asString() == "set_topIsLow") - { - if (command.get(1).asString() == "off") { - m_topIsLow = false; - reply.addString("ack"); - } else if (command.get(1).asString() == "on") { - m_topIsLow = true; - reply.addString("ack"); - } else { - reply.addString("err"); - } - } else if (command.get(0).asString() == "set_noise") { if (command.get(1).asString() == "off") { @@ -830,8 +817,6 @@ void FakeFrameGrabber::createTestImage(yarp::sig::ImageOf& image.pixel(6, 0).g = ttxt[19] - '0'; image.pixel(6, 0).b = ttxt[20] - '0'; } - - image.setTopIsLowIndex(m_topIsLow); } diff --git a/src/devices/fake/fakeFrameGrabber/FakeFrameGrabber_ParamsParser.cpp b/src/devices/fake/fakeFrameGrabber/FakeFrameGrabber_ParamsParser.cpp index f2ee36e15de..41069305209 100644 --- a/src/devices/fake/fakeFrameGrabber/FakeFrameGrabber_ParamsParser.cpp +++ b/src/devices/fake/fakeFrameGrabber/FakeFrameGrabber_ParamsParser.cpp @@ -8,7 +8,7 @@ // This is an automatically generated file. Please do not edit it. // It will be re-generated if the cmake flag ALLOW_DEVICE_PARAM_PARSER_GERNERATION is ON. -// Generated on: Thu Mar 7 17:59:43 2024 +// Generated on: Mon Sep 16 16:44:50 2024 #include "FakeFrameGrabber_ParamsParser.h" @@ -188,20 +188,6 @@ bool FakeFrameGrabber_ParamsParser::parseParams(const yarp::os::Searchable prop_check.unput("syncro"); } - //Parser of parameter topIsLow - { - if (config.check("topIsLow")) - { - m_topIsLow = config.find("topIsLow").asBool(); - yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'topIsLow' using value:" << m_topIsLow; - } - else - { - yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'topIsLow' using DEFAULT value:" << m_topIsLow; - } - prop_check.unput("topIsLow"); - } - //Parser of parameter physFocalLength { if (config.check("physFocalLength")) diff --git a/src/devices/fake/fakeFrameGrabber/FakeFrameGrabber_ParamsParser.h b/src/devices/fake/fakeFrameGrabber/FakeFrameGrabber_ParamsParser.h index 2d48b127b7d..d6c62b2aedb 100644 --- a/src/devices/fake/fakeFrameGrabber/FakeFrameGrabber_ParamsParser.h +++ b/src/devices/fake/fakeFrameGrabber/FakeFrameGrabber_ParamsParser.h @@ -8,7 +8,7 @@ // This is an automatically generated file. Please do not edit it. // It will be re-generated if the cmake flag ALLOW_DEVICE_PARAM_PARSER_GERNERATION is ON. -// Generated on: Thu Mar 7 17:59:43 2024 +// Generated on: Mon Sep 16 16:44:50 2024 #ifndef FAKEFRAMEGRABBER_PARAMSPARSER_H @@ -120,7 +120,6 @@ class FakeFrameGrabber_ParamsParser : public yarp::dev::IDeviceDriverParams std::string m_fakeFrameGrabber_rpc_port = {"/fakeFrameGrabber/rpc"}; bool m_mirror = {false}; bool m_syncro = {false}; - bool m_topIsLow = {true}; double m_physFocalLength = {3.0}; double m_focalLengthX = {4.0}; double m_focalLengthY = {5.0}; diff --git a/src/devices/fake/fakeFrameGrabber/FakeFrameGrabber_params.md b/src/devices/fake/fakeFrameGrabber/FakeFrameGrabber_params.md index 6a48cb19057..50a37a916d6 100644 --- a/src/devices/fake/fakeFrameGrabber/FakeFrameGrabber_params.md +++ b/src/devices/fake/fakeFrameGrabber/FakeFrameGrabber_params.md @@ -5,7 +5,6 @@ * | | fakeFrameGrabber_rpc_port | string | - | /fakeFrameGrabber/rpc | No | rpc port for the fakeFrameGrabber | | * | | mirror | bool | - | false | No | mirror height of test image | | * | | syncro | bool | - | false | No | synchronize producer and consumer, so that all images are used once and only once | | - * | | topIsLow | bool | - | true | No | explicitly set the topIsLow field in the images | | * | | physFocalLength | double | - | 3.0 | No | Physical focal length | | * | | focalLengthX | double | - | 4.0 | No | Horizontal component of the focal length | | * | | focalLengthY | double | - | 5.0 | No | Vertical component of the focal length | | From b590f07c324947c94398facd806b40702a47833d Mon Sep 17 00:00:00 2001 From: Marco Randazzo Date: Thu, 17 Oct 2024 12:15:41 +0200 Subject: [PATCH 3/3] removed topIsLow from yarpview --- src/yarpview/plugin/ImagePort.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/yarpview/plugin/ImagePort.cpp b/src/yarpview/plugin/ImagePort.cpp index b700db0532d..a3ff79c45ff 100644 --- a/src/yarpview/plugin/ImagePort.cpp +++ b/src/yarpview/plugin/ImagePort.cpp @@ -57,9 +57,12 @@ void InputCallback::onRead(yarp::sig::ImageOf &img) j+=4; }*/ - if (img.topIsLowIndex()) { + if (1) + { memcpy(tmpBuf, rawImg, imgSize); - } else { + } + else + { //flip the image along the y axis for(int x = 0; x < s.height(); x++) { memcpy(tmpBuf + x * img.getRowSize(), rawImg + (s.height() - x - 1) * img.getRowSize(),