[Reprinted] Some Macros in opencv

Source: Internet
Author: User

Some Macros in opencv

 

Address: http://blog.csdn.net/wqvbjhc/archive/2010/04/17/5496632.aspx

 

Cv_funcname defines the variable cvfuncname to store the function name. It is used to report the function with an error when an error occurs.

_ File _ macro in C language, which is often used in cv_error. It indicates the source file name of the faulty function.

_ Line _ macro in C language, which is often used in cv_error to indicate the error location.

In cxerror. h

View plaincopy to clipboardprint?
/* Cv_funcname macro defines icvfuncname constant which is used by cv_error macro */
# Ifdef cv_no_func_names
# Define cv_funcname (name)
# Define cvfuncname ""
# Else
# Define cv_funcname (name )/
Static char cvfuncname [] = Name
# Endif
/*
Cv_error macro unconditionally raises error with passed code and message.
After raising error, control will be transferred to the exit label.
*/
# Define cv_error (Code, MSG )/
{/
Cverror (CODE), cvfuncname, MSG, _ file __, _ line __);/
Exit ;/
}
/* Cv_funcname macro defines icvfuncname constant which is used by cv_error macro */
# Ifdef cv_no_func_names
# Define cv_funcname (name)
# Define cvfuncname ""
# Else
# Define cv_funcname (name )/
Static char cvfuncname [] = Name
# Endif
/*
Cv_error macro unconditionally raises error with passed code and message.
After raising error, control will be transferred to the exit label.
*/
# Define cv_error (Code, MSG )/
{/
Cverror (CODE), cvfuncname, MSG, _ file __, _ line __);/
Exit ;/
}
 

2.

_ Begin _ and _ end _ are used together. When an error occurs, exit

In cxerror. h

# DEFINE _ begin __{
# DEFINE _ end _ goto exit; exit :;}
# DEFINE _ cleanup __
# Define exit goto exit

Add a semicolon after _ begin _ and _ end _ in the Code:

Because _ begin __; is equivalent to {;, where semicolon (;) is an empty statement, it is reasonable, but do not use. _ end _ as well.

View plaincopy to clipboardprint?
Int I;
;
;
Int B;
Int I;
;
;
Int B;

This syntax is correct.

3.

Cv_cn_max 64 // The maximum number of channels is 64

Cv_depth_max = 8 = (1000) // The maximum depth is 8.

Cv_mat_type_mask 11111111 // 511

Cv_mat_type (flags) & cv_mat_depth_mask) // flags and flags must be flags, but flags must be between 0 and 511.

Cv_mat_depth_mask = 7 = (0111) // bit deep mask to ensure the maximum value is 8 (the remaining number)

Cv_mat_cn_mask = (111111,000) // mask

Cv_mat_cn

Cv_mat_depth: Obtain the depth. The depth ranges from 8 to 0 ~ 7

Cv_elem_size = number of channels x depth = number of channels> X = number of bytes per pixel

Cv_maketype (depth, CN) (cv_mat_depth (depth) + (CN)-1) <cv_cn_shift) // shifts the cn-1 three places left (that is, multiply by 8) and then add to depth

In cxtypes. h

View plaincopy to clipboardprint?
/* 0x3a50 = 11 10 10 01 01 00 ~ Array of log2 (sizeof (arr_type_elem ))*/
# Define cv_elem_size (type )/
(Cv_mat_cn (type) <(sizeof (size_t)/4 + 1) * 16384 | 0x3a50)> cv_mat_depth (type) * 2) & 3 ))
# Define cv_cn_max 64
# Define cv_mat_cn_mask (cv_cn_max-1) <cv_cn_shift)
# Define cv_mat_cn (flags) & cv_mat_cn_mask)> cv_cn_shift) + 1)
# Define cv_mat_depth (flags) & cv_mat_depth_mask)
# Define cv_mat_depth_mask (cv_depth_max-1)
# Define cv_cn_shift 3
# Define cv_depth_max (1 <cv_cn_shift)

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.