Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize Matrix element Serialization with OpenCV reshape function

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article focuses on "how to use the OpenCV reshape function to serialize matrix elements", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to serialize matrix elements with OpenCV reshape functions.

In opencv, the reshape function is more interesting, it can not only change the number of channels of the matrix, but also serialize the matrix elements, a very useful function.

Function prototype:

Caterpillar: Mat Mat::reshape (int cn, int rows=0) const

There are few parameters, but you have to be careful when setting them.

Cn: indicates the number of channels (channels). If set to 0, the number of channels remains the same, otherwise it becomes the set number of channels.

Rows: represents the number of matrix rows. If set to 0, it means that the original number of rows remains the same, otherwise it becomes the set number of rows.

First set up an initial matrix: a matrix of 20 rows, 30 columns and 1 channel

Int main () {Mat data = Mat (20,30, CV_32F); / / set a matrix cout of 20 rows, 30 columns and 1 channel

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report