No viable conversion from 'Dims' (aka 'nvinfer1::Dims32') to 'nvinfer1::DimsHW' candidate constructor (the implicit copy constructor) not viable: cannot bind base class object of type 'Dims' (aka 'nvinfer1::Dims32') to derived class reference 'const nvinfer1::DimsHW &' for 1st argument candidate constructor (the implicit move constructor) not viable: cannot bind base class object of type 'Dims' (aka 'nvinfer1::Dims32') to derived class reference 'nvinfer1::DimsHW &&' for 1st argument
时间: 2023-12-23 11:06:25 浏览: 154
对不起,我之前的回答有误。在打印 `shuffle22_0` 和 `cat22_0` 的形状时,需要将 `nvinfer1::Dims` 类型转换为 `nvinfer1::DimsHW` 类型。
请使用以下代码进行转换并打印形状:
```cpp
nvinfer1::DimsHW shuffle22_0_shape;
shuffle22_0_shape = static_cast<nvinfer1::DimsHW&>(shuffle22_0->getOutput(0)->getDimensions());
std::cout << "shuffle22_0 shape: " << shuffle22_0_shape.h() << ", " << shuffle22_0_shape.w() << std::endl;
```
这将输出 `shuffle22_0` 的形状。同样的方法也适用于打印 `cat22_0` 的形状。对于 `nvinfer1::DimsHW` 类型的对象,可以使用 `.h()` 和 `.w()` 方法获取高度和宽度。
相关问题
MqttServer.cpp:125:43: No viable conversion from 'std::string' (aka 'basic_string<char>') to 'const QByteArray' qbytearray.h:181:5: candidate constructor not viable: no known conversion from 'std::string' (aka 'basic_string<char>') to 'const char *' for 1st argument qbytearray.h:189:12: candidate constructor not viable: no known conversion from 'std::string' (aka 'basic_string<char>') to 'QByteArray &&' for 1st argument qbytearray.h:463:12: candidate constructor not viable: no known conversion from 'std::string' (aka 'basic_string<char>') to 'QByteArrayDataPtr' for 1st argument qbytearray.h:524:20: candidate constructor not viable: no known conversion from 'std::string' (aka 'basic_string<char>') to 'const QByteArray &' for 1st argument qbytearray.h:405:67: passing argument to parameter 'hexEncoded' here
这个错误的意思是说,你正在尝试将一个`std::string`类型的变量转换为`QByteArray`类型,但是`QByteArray`没有一个可以接受`std::string`类型参数的构造函数。
要解决这个问题,你需要将`std::string`类型转换为`QByteArray`类型。你可以使用`QByteArray::fromStdString()`函数来实现这一点,例如:
```
std::string myString = "hello";
QByteArray myByteArray = QByteArray::fromStdString(myString);
```
这将把`myString`转换为一个`QByteArray`类型的变量`myByteArray`。你可以在你的代码中使用类似的方法来解决这个问题。
widget.cpp:170:33: error: no viable conversion from 'osgEarth::SkyNode *' to 'osg::ref_ptr<osg::Drawable>' ref_ptr:37:9: note: candidate constructor not viable: no known conversion from 'osgEarth::SkyNode *' to 'osg::Drawable *' for 1st argument ref_ptr:38:9: note: candidate constructor not viable: no known conversion from 'osgEarth::SkyNode *' to 'const osg::ref_ptr<osg::Drawable> &' for 1st argument ref_ptr:40:9: note: candidate constructor not viable: no known conversion from 'osgEarth::SkyNode *' to 'observer_ptr<osg::Drawable> &' for 1st argument ref_ptr:39:31: note: candidate template ignored: could not match 'ref_ptr<type-parameter-0-0>' against 'osgEarth::SkyNode *'
看起来你正在将 `osgEarth::SkyNode` 类型的对象直接赋值给了 `osg::ref_ptr<osg::Drawable>` 类型的变量,这是不兼容的,因为 `SkyNode` 并不是继承自 `Drawable`。
正确的写法应该是创建一个 `osg::Geode` 对象,将 `SkyNode` 添加到 `osg::Geode` 中,然后将 `osg::Geode` 添加到场景图中。以下是一个示例代码:
```
osg::ref_ptr<osg::Geode> skyGeode = new osg::Geode();
osg::ref_ptr<osgEarth::Util::SkyNode> skyNode = new osgEarth::Util::SkyNode(osgEarth::Util::SkyOptions());
skyGeode->addDrawable(skyNode.get());
root->addChild(skyGeode.get());
```
这将创建一个 `osgEarth::Util::SkyNode` 对象,并将其添加到 `osg::Geode` 中,然后将 `osg::Geode` 添加到场景图中。
阅读全文