我正在使用tensorRT進行嵌入式深度學習推理C++項目。 對於我的模型,有必要減去平均圖像。爲嵌入式系統加載png圖像
,我使用的API,允許我定義與RGB圖像以下數據結構的平均影像:
uint8_t *data[DW_MAX_IMAGE_PLANES]; // raw image data
size_t pitch; // pitch of the image in bytes
uint32_t height; // height of the image in px
uint32_t width; // image width in px
uint32_t planeCount; // plane count of the image
到目前爲止,我發現的lib LodePNG,這是非常有用的這個任務我認爲。 它可以只用幾行加載png格式:
// Load file and decode image.
std::vector<unsigned char> image;
unsigned width, height;
unsigned error = lodepng::decode(image, width, height, filename);
的,現在的問題是如何std::vector<unsigned char>
轉換爲uint8_t *[DW_MAX_IMAGE_PLANES]
和計算音調和planeCount值?
由於我使用的是RGB圖像DW_MAX_IMAGE_PLANES等於爲pitch
和planeCount
簡單3.
你的問題的標題似乎有點不對,因爲你已經成功加載了PNG。 –
也許一個['std :: vector'](http://en.cppreference.com/w/cpp/container/vector)引用可能有用?有幾種方法可以獲得由矢量管理的數據的指針,包括(但不限於)獲取指向其第一個元素的指針。 –
至於其餘部分,您提供的元數據庫不是嗎? –