open cv+C++错误及经验总结(六)

27 篇文章 0 订阅
21 篇文章 4 订阅

DDX-dialog Data Exchange对话框数据交换

DDV-Dialog Data Validation对话框数据校验

获得窗口句柄的方法:利用GetNextDlgTabItem函数来实现。

GetNextDlgTabItem(HWND hDlg, HWND hCtl, BOOL  bPrevious)

HWND WINAPI GetNextDlgTabItem(
  _In_      HWND hDlg,
  _In_opt_  HWND hCtl,
  _In_      BOOL bPrevious
);
Parameters

hDlg [in]

Type: HWND

A handle to the dialog box to be searched.被搜索的对话框句柄

hCtl [in, optional]

Type: HWND

A handle to the control to be used as the starting point for the search. If this parameter is NULL, the function fails.指定用来作为开始点的控制句柄,如果此参数为NULL,函数失败。

bPrevious [in]

Type: BOOL

Indicate how the function is to search the dialog box.If this parameter is TRUE, the function searches for the previous controlin the dialog box.If this parameter is FALSE, the function searches for the next control in the dialog box.

表明函数是如何搜索对话框的。如果此参数为TRUE,函数将会搜索对话框的前一个控件。如果此参数为FALSE,函数将会搜索对话框中的下一个控件。

Return value

Type: HWND

If the function succeeds, the return value is the window handle of the previous (or next)control that has the WS_TABSTOP style set.如果函数成功,返回值是前一个或后一个窗口的句柄,句柄的类型是WS_TABSTOP.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.如果函数失败,返回值是NULL。获取更详细的信息,调用GetLastError.

Remarks

The GetNextDlgTabItem function searches controls in the order ( or reverse order)they were created in the dialog box template. The function returns the first control it locates that is visible, not disabled,and has the WS_TABTOP style. If no such control exists, the function returns hCtl.

GetNextDlgTabItem函数搜索控件按照其对话框模板中的创建顺序来进行。函数返回第一个位置上可视,且不失效的控件,该控件具有WS_TABTOP风格。如果不存在此控件,函数返回hCtrl.

If the search for the next control with the WS_TABSTOP style encounters a window with the WS_EX_CONTROLPARENT style, the systemrecusively searchs the window's children.

如果寻找下一个具有WS_TABSTOP风格的窗口时遇到具有WS_EX_CONTROLPARENT风格的窗口,系统会递归的寻找其子窗口。

recursively英 [rɪ'kəsɪvlɪ] 美 [rɪ'kəsɪvlɪ] [计] 递归地


retrieved英 [rɪ'tri:vd] 美 [rɪ'tri:vd]

v.   

SetwindowLong()函数的使用方法

如何打开对话框资源编辑器?

保证应用程序只有一个实例运行

通过创建一个命名的事件对象,也可以实现应用程序只有一个实例运行这一功能。对CreateEvent函数来说,如果创建的是命名的事件对象,并且在此函数调用之前此事件对象已经存在,那么该函数将返回已存在的这个事件对象的句柄,并且之后的GetLastError调用将返回ERROR_ALREADY_EXISTS.

利用CreateEvent函数创建命名事件对象并根据其返回值判断应用程序是否已经有一个实例在运行,如果有,则应用程序退出,从而实现应用程序只有一个实例运行这一功能。

关键代码段

在进入关键代码段之前,首先需要初始化一个这样的关键代码段,这可以调用InitializeCriticalSection函数实现。

void  InitializeCriticalSection(LPCRITICAL_SECTION  lpCriticalSection);

descriptor

生词本
英 [dɪˈskrɪptə(r)]
美 [dɪˈskrɪptɚ]

n.

WSAAsyncSelect function

The WSAAsyncSelect function requests Windows message-based notification of network events for a socket.该函数为指定的套接字请求基于Windows消息的网络事件通知,并自动将该套接字设置为非阻塞模式。

Syntax

C++
int WSAAsyncSelect(
  _In_  SOCKET s,
  _In_  HWND hWnd,
  _In_  unsigned int wMsg,
  _In_  long lEvent
);

Parameters

s [in]

A descriptor that identifies the socket for which event notification is required. 标识一个需要事件通知的套接口的描述符.

hWnd [in]

A handle that identifies the window that will receive a message when a network event occurs.标识一个在网络事件发生时需要接收消息的窗口句柄.

wMsg [in]

A message to be received when a network event occurs.在网络事件发生时要接收的消息.

lEvent [in]

A bit mask that specifies a combination of network events in which the application is interested.位屏蔽码,用于指明应用程序感兴趣的网络事件集合.

美 [prəˈvaɪdɪd ðæt]

Return value

If the WSAAsyncSelect function succeeds, the return value is zero, provided thatthe application's declaration of interest in the network event set was successful. Otherwise, the value SOCKET_ERROR is returned, and a specific error number can be retrieved by calling WSAGetLastError.

Error code Meaning
WSANOTINITIALISED

A successful WSAStartup call must occur before using this function.

WSAENETDOWN

The network subsystem failed.

WSAEINVAL

One of the specified parameters was invalid, such as the window handle not referring to an existing window, or the specified socket is in an invalid state.

WSAEINPROGRESS

A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function.

WSAENOTSOCK

The descriptor is not a socket.

 

Additional error codes can be set when an application window receives a message. This error code is extracted from thelParam in the reply message using the WSAGETSELECTERROR macro.Possible error codes for each network event are listed in the following table.

retrieved

生词本
去背诵
英 [rɪ'tri:vd] 美 [rɪ'tri:vd]

v.   

Transport

生词本
去背诵
英 ['trænspɔ:t]
美 [trænsˈpɔrt, -ˈport]

vt.  

n.   

protocol

生词本
去背诵
英 ['prəʊtəkɒl]
美 [ˈprotəˌkɔl, -ˌkol, -ˌkɑl]

n.   

vt.

vi.

WSAEnumProtocols function

The WSAEnumProtocols function retrieves information about available transport protocols.函数检索可用的网络传输协议信息

Syntax

C++
int WSAEnumProtocols(
  _In_     LPINT lpiProtocols,
  _Out_    LPWSAPROTOCOL_INFO lpProtocolBuffer,
  _Inout_  LPDWORD lpdwBufferLength
);

Parameters

lpiProtocols [in]

NULLl-terminated array of iProtocol values. This parameter is optional; if lpiProtocols is NULL, information on all available protocols is returned. Otherwise, information is retrieved only for those protocols listed in the array.一个NULL结束的iProtocol数组。这个信息是可选项;如果lpiProtocols是NULL,所有可用的协议信息都将返回。否则,信息将仅更新数组列表中列出的协议。

lpProtocolBuffer [out]

A pointer to a buffer that is filled with WSAPROTOCOL_INFO structures.缓冲区的指针,缓冲区是一个WSAPROTOCOL_INFO的结构体。

lpdwBufferLength [in, out]

On input, number of bytes in the lpProtocolBuffer buffer passed to WSAEnumProtocols. On output, the minimum buffer size that can be passed to WSAEnumProtocols toretrieve all the requested information.This routine has no ability to enumerate over multiple calls; the passed-in buffer must be large enough to hold all entries in order for the routine to succeed. This reduces the complexity of the API and should not pose a problem because the number of protocols loaded ona computer is typically small.

输入值,传送给WSAEnumProtocols函数的lpProtocolBuffer缓冲区的字节数。

输出值,传递给WSAEnumProtocols函数的最小的缓冲区大小,缓冲区用于获取所有的请求信息。This routine(WSAEnumProtocols函数)不能重复调用;为了使WSAEnumProtocols函数(routine成功,传入的缓冲区必须足够大以容纳所有的条目。这样做减少了API的复杂性及减少问题,因为计算机载入的协议数非常少。

Return value

If no error occurs, WSAEnumProtocols returns the number of protocols to be reported. Otherwise, a value of SOCKET_ERROR is returned and a specific error codecan be retrieved by calling WSAGetLastError.

enumerate

生词本
英 [ɪ'nju:məreɪt]
美 [ɪˈnuməˌret, ɪˈnju-]

vt.

英 [ru:ˈti:n]
美 [ruˈtin]

n.   

adj.   

WSAStartup function

The WSAStartup function initiates use of the Winsock DLL by a process.

WSAStartup函数将初始化进程使用的WS2_32.DLL

Syntax

C++
int WSAStartup(
  _In_   WORD wVersionRequested,
  _Out_  LPWSADATA lpWSAData
);

Parameters

wVersionRequested [in]

The highest version of Windows Sockets specification that the caller can use. The high-order byte specifies the minor version number; the low-order byte specifiesthe major version number.调用者能够使用的windows套接字的最高版本。该参数的高位字节指定Winsock库的副版本,而低位字节则是主版本

lpWSAData [out]

A pointer to the WSADATA data structure that is to receive details of the Windows Sockets implementation.

指向WSADATA数据结构的指针,它用来接收windows sockets 实现的细节。

Return value

If successful, the WSAStartup function returns zero. Otherwise, it returns one of the error codes listed below.

The WSAStartup function directly returns theextended error code in the return value for this function. A call to theWSAGetLastError function is not needed and should not be used.

extended error code

specification英 [ˌspesɪfɪˈkeɪʃn]  



美 [ˌspɛsəfɪˈkeʃən]  

n.    
英 ['maɪnə(r)]
美 [ˈmaɪnɚ]

adj.   

n.   

vi.

英 ['meɪdʒə(r)]
美 [ˈmedʒɚ]

adj.   

n.   

vi.  

WSASocket function

The WSASocket function creates a socket that is bound to a specific transport-service provider.

WSA函数创建一个套接字,该套接字与一个具体的传输服务提供者绑定。

Syntax

C++
SOCKET WSASocket(
  _In_  int af,
  _In_  int type,
  _In_  int protocol,
  _In_  LPWSAPROTOCOL_INFO lpProtocolInfo,
  _In_  GROUP g,
  _In_  DWORD dwFlags
);

Parameters

af [in]

The address family specification. Possible values for the address family are defined in the Winsock2.h header file.:一个地址描述。在Winsock2.h的头文件中定义了address family的可能值。

On the Windows SDK released for Windows Vista and later, the organization of header files has changed and the possible values for the address family are defined in the Ws2def.h header file. Note that the Ws2def.h header file is automatically included in Winsock2.h, and should never be used directly.

windows Vista稍后公布的windows sdk中,头文件的组织被改变了,address family的可能值被定义在了Ws2def.h头文件。Ws2def.h头文件自动被包含进Winsock.h中,并不会被直接使用。

The values currently supported are AF_INET or AF_INET6, which are the Internet address family formats for IPv4 and IPv6. Other options for address family (AF_NETBIOS for use with NetBIOS, for example) are supported if a Windows Sockets service provider for the address family is installed. Note that the values for the AF_ address family and PF_ protocol family constants are identical (for example, AF_INET and PF_INET), so either constant can be used.

目前支持AF_INET或AF_INET6两位值,他们是IPv4 和IPv6的网络地址族(address family)格式。地址族的其他可选项(例如NetBIOS同AF_NETBIOS一起使用)在windows套接字服务提供者为其建立后将会可用。需要注意的是AF_的地址族和PF_的协议族的常量值是一个标示符(例如AF_INET和PF_INET),所以其他常量也可以被使用。

The table below lists common values for address family although many other values are possible.

下表列出了地址族的常用值。

1. 以便使用
2. 供使用

Af Meaning
AF_UNSPEC 0

The address family is unspecified.

AF_INET 2

The Internet Protocol version 4 (IPv4) address family.

AF_IPX 6

The IPX/SPX address family. This address family is only supported if the NWLink IPX/SPX NetBIOS Compatible Transport protocol is installed.

This address family is not supported on Windows Vista and later.

AF_APPLETALK 16

The AppleTalk address family. This address family is only supported if the AppleTalk protocol is installed.

This address family is not supported on Windows Vista and later.

AF_NETBIOS 17

The NetBIOS address family. This address family is only supported if the Windows Sockets provider for NetBIOS is installed.

The Windows Sockets provider for NetBIOS is supported on 32-bit versions of Windows. This provider is installed by default on 32-bit versions of Windows.

The Windows Sockets provider for NetBIOS is not supported on 64-bit versions of windows including Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003, or Windows XP.

The Windows Sockets provider for NetBIOS only supports sockets where the type parameter is set to SOCK_DGRAM.

The Windows Sockets provider for NetBIOS is not directly related to the NetBIOS programming interface. The NetBIOS programming interface is not supported on Windows Vista, Windows Server 2008, and later.

AF_INET6 23

The Internet Protocol version 6 (IPv6) address family.

AF_IRDA 26

The Infrared Data Association (IrDA) address family.

This address family is only supported if the computer has an infrared port and driver installed.

AF_BTH 32

The Bluetooth address family.

This address family is supported on Windows XP with SP2 or later if the computer has a Bluetooth adapter and driver installed.

 

type [in]

The type specification for the new socket.指定socket类型。

Possible values for the socket type are defined in the Winsock2.h header file.

The following table lists the possible values for the type parameter supported for Windows Sockets 2:

Type Meaning
SOCK_STREAM 1

A socket type that provides sequenced, reliable, two-way, connection-based byte streams with an OOB data transmission mechanism. This socket type uses the Transmission Control Protocol (TCP) for the Internet address family (AF_INET or AF_INET6).

SOCK_DGRAM 2

A socket type that supports datagrams, which are connectionless, unreliable buffers of a fixed (typically small) maximum length. This socket type uses the User Datagram Protocol (UDP) for the Internet address family (AF_INET or AF_INET6).

SOCK_RAW 3

A socket type that provides a raw socket that allows an application to manipulate the next upper-layer protocol header. To manipulate the IPv4 header, the IP_HDRINCL socket option must be set on the socket. To manipulate the IPv6 header, the IPV6_HDRINCL socket option must be set on the socket.

SOCK_RDM 4

A socket type that provides a reliable message datagram. An example of this type is the Pragmatic General Multicast (PGM) multicast protocol implementation in Windows, often referred to as reliable multicast programming.

This type value is only supported if the Reliable Multicast Protocol is installed.

SOCK_SEQPACKET 5

A socket type that provides a pseudo-stream packet based on datagrams.

 

specifying  英 ['spesɪfaɪʃ]  美 ['spesɪfaɪʃ]

v.   

periodically

生词本
去背诵
英 [ˌpɪərɪ'ɒdɪklɪ]
美 [pɪrɪˈɑdɪklɪ]

adv. 

网 络
  • 周期性地;
  • 定期地;
  • 周期性的,定时性的;
  • 周期地

specific

生词本
去背诵
英 [spəˈsɪfɪk]
美 [spɪˈsɪfɪk]

adj.   

n.   

specific to

网 络
  • 特定于;
  • 针对;
  • 特定于,针对;
  • 具有特异性

In Windows Sockets 2, new socket types were introduced. An application can dynamicallydiscover the attributes of each available transport protocol through the WSAEnumProtocols function.So an application can determine the possible socket type and protocol options for an address family and use this information when specifying this parameter. Socket type definitions in the Winsock2.h and Ws2def.h header files will be periodically updated as new socket types, address families, and protocols are defined.

Windows 套接字2会介绍新的套接字类型。通过WSAEnumProtocols函数,应用程序会动态的获得每一个可用传输协议的属性。因此,在指定该参数时,应用程序能够为地址族决定可选的套接字类型和协议选项。套接字类型定义在Winsock.h和Ws2def.h头文件中,头文件会随着新套接字类型、地址族和协议被定义时定期更新。

In Windows Sockets 1.1, the only possible socket types are SOCK_DGRAM and SOCK_STREAM.

protocol [in]

The protocol to be used. The possible options for the protocol parameter are specific to the address family and socket type specified. Possible values for the protocol  are defined in the Winsock2.h and Wsrm.h header files.

将被使用的协议。可能的选项仅限于地址族和指定的套接字类型。

On the Windows SDK released for Windows Vista and later,, the organization of header files has changed and this parameter can be one of the values from the IPPROTO enumeration type defined in the Ws2def.h header file. Note that the Ws2def.h header file is automatically included in Winsock2.h, and should never be used directly.

在Windows Vista及稍后发布的Windows SDK。头文件会改变。参数是IPPROTO枚举类型的值之一。IPPROTO在Ws2def.h中被定义。需要注意的是,Ws2def.h头文件自动被包含进Winsock.h中,并不会被直接使用。

choose to use

网 络
  • 选择用;
  • 选择采用;
  • 选择使用;
  • 选择使用信

If a value of 0 is specified,the caller does not wish to specify a protocol and the service provider will choose the protocol to use.

调用者不指定协议,由服务提供者来指定协议。

When the af parameter is AF_INET or AF_INET6 and the type is SOCK_RAW, the value specified for the protocol is set in the protocol field of the IPv6 or IPv4 packet header.

The table below lists common values for the protocol although many other values are possible.

protocol Meaning
IPPROTO_ICMP 1

The Internet Control Message Protocol (ICMP). This is a possible value when the afparameter is AF_UNSPECAF_INET, or AF_INET6 and the type parameter is SOCK_RAWor unspecified.

This protocol value is supported on Windows XP and later.

IPPROTO_IGMP 2

The Internet Group Management Protocol (IGMP). This is a possible value when the afparameter is AF_UNSPECAF_INET, or AF_INET6 and the type parameter is SOCK_RAWor unspecified.

This protocol value is supported on Windows XP and later.

BTHPROTO_RFCOMM 3

The Bluetooth Radio Frequency Communications (Bluetooth RFCOMM) protocol. This is a possible value when the af parameter is AF_BTH and the type parameter isSOCK_STREAM.

This protocol value is supported on Windows XP with SP2 or later.

IPPROTO_TCP 6

The Transmission Control Protocol (TCP). This is a possible value when the af parameter is AF_INET or AF_INET6 and the type parameter is SOCK_STREAM.

IPPROTO_UDP 17

The User Datagram Protocol (UDP). This is a possible value when the af parameter isAF_INET or AF_INET6 and the type parameter is SOCK_DGRAM.

IPPROTO_ICMPV6 58

The Internet Control Message Protocol Version 6 (ICMPv6). This is a possible value when the af parameter is AF_UNSPECAF_INET, or AF_INET6 and the type parameter isSOCK_RAW or unspecified.

This protocol value is supported on Windows XP and later.

IPPROTO_RM 113

The PGM protocol for reliable multicast. This is a possible value when the af parameter isAF_INET and the type parameter is SOCK_RDM. On the Windows SDK released for Windows Vista and later, this protocol is also called IPPROTO_PGM.

This protocol value is only supported if the Reliable Multicast Protocol is installed.

 

lpProtocolInfo [in]

A pointer to a WSAPROTOCOL_INFO structure that defines the characteristics of the socket to be created. If this parameter is not NULL, the socket will be bound to the provider associated with the indicatedWSAPROTOCOL_INFO structure.如果lpProtocolInfo不为NULL,则套接字绑定到与指定的结构WSAPROTOCOL_INFO相关的提供者。

g [in]

An existing socket group ID or an appropriate action to take when creating a new socket and a new socket group.当创建新的套接字和套接字组的时候,一个存在的套接字组ID或者恰当的行为被执行。

If g is an existing socket group ID, join the new socket to this socket group, provided all the requirements set by this group are met.

If g is not an existing socket group ID, then the following values are possible.

g Meaning
0

No group operation is performed.

SG_UNCONSTRAINED_GROUP 0x01

Create an unconstrained socket group and have the new socket be the first member. For an unconstrained group, Winsock does not constrain all sockets in the socket group to have been created with the same value for the type andprotocol parameters.

SG_CONSTRAINED_GROUP 0x02

Create a constrained socket group and have the new socket be the first member. For a contrained socket group, Winsock constrains all sockets in the socket group to have been created with the same value for the type andprotocol parameters. A constrained socket group may consist only of connection-oriented sockets, and requires that connections on all grouped sockets be to the same address on the same host.

 

Note  The SG_UNCONSTRAINED_GROUP and SG_CONSTRAINED_GROUP constants are not currently defined in a public header file.

dwFlags [in]

A set of flags used to specify additional socket attributes.一组标志用来标示额外的套接字属性

A combination of these flags may be set, although some combinations are not allowed.

Value Meaning
WSA_FLAG_OVERLAPPED 0x01

Create a socket that supports overlapped I/O operations.

Most sockets should be created with this flag set. Overlapped sockets can utilize WSASendWSASendToWSARecvWSARecvFrom, andWSAIoctl for overlapped I/O operations, which allow multiple operations to be initiated and in progress simultaneously.

All functions that allow overlapped operation (WSASendWSARecv,WSASendToWSARecvFromWSAIoctl) also support nonoverlapped usage on an overlapped socket if the values for parameters related to overlapped operations are NULL.

WSA_FLAG_MULTIPOINT_C_ROOT 0x02

Create a socket that will be a c_root in a multipoint session.

This attribute is only allowed if the WSAPROTOCOL_INFO structure for the transport provider that creates the socket supports a multipoint or multicast mechanism and the control plane for a multipoint session is rooted. This would be indicated by thedwServiceFlags1 member of the WSAPROTOCOL_INFO structure with the XP1_SUPPORT_MULTIPOINT andXP1_MULTIPOINT_CONTROL_PLANE flags set.

When the lpProtocolInfo parameter is not NULL, theWSAPROTOCOL_INFO structure for the transport provider is pointed to by the lpProtocolInfo parameter. When the lpProtocolInfoparameter is NULL, the WSAPROTOCOL_INFO structure is based on the transport provider selected by the values specified for the aftype, and protocol parameters.

Refer to Multipoint and Multicast Semantics for additional information on a multipoint session.

WSA_FLAG_MULTIPOINT_C_LEAF 0x04

Create a socket that will be a c_leaf in a multipoint session.

This attribute is only allowed if the WSAPROTOCOL_INFO structure for the transport provider that creates the socket supports a multipoint or multicast mechanism and the control plane for a multipoint session is non-rooted. This would be indicated by thedwServiceFlags1 member of the WSAPROTOCOL_INFO structure with the XP1_SUPPORT_MULTIPOINT flag set and theXP1_MULTIPOINT_CONTROL_PLANE flag not set.

When the lpProtocolInfo parameter is not NULL, theWSAPROTOCOL_INFO structure for the transport provider is pointed to by the lpProtocolInfo parameter. When the lpProtocolInfoparameter is NULL, the WSAPROTOCOL_INFO structure is based on the transport provider selected by the values specified for the aftype, and protocol parameters.

Refer to Multipoint and Multicast Semantics for additional information on a multipoint session.

WSA_FLAG_MULTIPOINT_D_ROOT 0x08

Create a socket that will be a d_root in a multipoint session.

This attribute is only allowed if the WSAPROTOCOL_INFO structure for the transport provider that creates the socket supports a multipoint or multicast mechanism and the data plane for a multipoint session is rooted. This would be indicated by the dwServiceFlags1member of the WSAPROTOCOL_INFO structure with theXP1_SUPPORT_MULTIPOINT and XP1_MULTIPOINT_DATA_PLANEflags set.

When the lpProtocolInfo parameter is not NULL, theWSAPROTOCOL_INFO structure for the transport provider is pointed to by the lpProtocolInfo parameter. When the lpProtocolInfoparameter is NULL, the WSAPROTOCOL_INFO structure is based on the transport provider selected by the values specified for the aftype, and protocol parameters.

Refer to Multipoint and Multicast Semantics for additional information on a multipoint session.

WSA_FLAG_MULTIPOINT_D_LEAF 0x10

Create a socket that will be a d_leaf in a multipoint session.

This attribute is only allowed if the WSAPROTOCOL_INFO structure for the transport provider that creates the socket supports a multipoint or multicast mechanism and the data plane for a multipoint session is non-rooted. This would be indicated by thedwServiceFlags1 member of the WSAPROTOCOL_INFO structure with the XP1_SUPPORT_MULTIPOINT flag set and theXP1_MULTIPOINT_DATA_PLANE flag not set.

When the lpProtocolInfo parameter is not NULL, theWSAPROTOCOL_INFO structure for the transport provider is pointed to by the lpProtocolInfo parameter. When the lpProtocolInfoparameter is NULL, the WSAPROTOCOL_INFO structure is based on the transport provider selected by the values specified for the aftype, and protocol parameters.

Refer to Multipoint and Multicast Semantics for additional information on a multipoint session.

WSA_FLAG_ACCESS_SYSTEM_SECURITY 0x40

Create a socket that allows the the ability to set a security descriptor on the socket that contains a security access control list (SACL) as opposed to just a discretionary access control list (DACL).

SACLs are used for generating audits and alarms when an access check occurs on the object. For a socket, an access check occurs to determine whether the socket should be allowed to bind to a specific address specified to the bind function.

The ACCESS_SYSTEM_SECURITY access right controls the ability to get or set the SACL in an object's security descriptor. The system grants this access right only if the SE_SECURITY_NAME privilege is enabled in the access token of the requesting thread.

WSA_FLAG_NO_HANDLE_INHERIT 0x80

Create a socket that is non-inheritable.

A socket handle created by the WSASocket or the socket function is inheritable by default. When this flag is set, the socket handle is non-inheritable.

The GetHandleInformation function can be used to determine if a socket handle was created with theWSA_FLAG_NO_HANDLE_INHERIT flag set. TheGetHandleInformation function will return that theHANDLE_FLAG_INHERIT value is set.

This flag is supported on Windows 7 with SP1, Windows Server 2008 R2 with SP1, and later

 

Important  For multipoint sockets, only one of WSA_FLAG_MULTIPOINT_C_ROOT orWSA_FLAG_MULTIPOINT_C_LEAF flags can be specified, and only one of WSA_FLAG_MULTIPOINT_D_ROOT orWSA_FLAG_MULTIPOINT_D_LEAF flags can be specified. Refer to Multipoint and Multicast Semantics for additional information.

Return value

If no error occurs, WSASocket returns a descriptor referencing the new socket. Otherwise, a value of INVALID_SOCKET is returned, and a specific error code can be retrieved by calling WSAGetLastError.  descriptor描述符

Note  This error code description is Microsoft-specific.

15章多线程,15.6网络聊天室程序的实现

16章线程同步与异步套接字编程,16.5.2网络聊天室程序的实现

intensity  英 [ɪn'tensətɪ]美 [ɪnˈtɛnsɪti]    n.   

corresponding to英 [ˌkɔrisˈpɔndiŋ tu:]美 [ˌkɔrɪˈspɑndɪŋ tu]  相当于…,与…相一致

with respect to  英[wið risˈpekt tu:]美 [wɪð rɪˈspɛkt tu]  关于, (至于)谈到

effectuate英 [ɪ'fektʃʊeɪt]美 [ɪ'fektʃʊeɪt]vt.实行,完成

depict   英 [dɪ'pɪkt]美 [dɪˈpɪkt]   vt. 

plot英 [plɒt]美 [plɑt]

n.   

vt.   

vi.  

Basic Thresholding Operation 基本阈值操作

Separate out regions of an imagecorresponding to objects which we want to analyze. This separation is based on thevariation of intensitybetween the object pixels and the background pixels.

分离出我们想分析的目标物体,这种分割是基于目标像素与背景像素的灰度差异来进行的。

Making your own linear filters!线性滤波

essentially

去背

英 [ɪˈsenʃəli]
美 [ɪˈsenʃəli]

adv.  

numerical

英 [nju:ˈmerɪkl]
美 [nuˈmɛrɪkəl, nju-]

adj.

coefficient     英 [ˌkəʊɪˈfɪʃnt]

美 [ˌkoəˈfɪʃənt]

n.   

adj. 

overlaying

英 ['əʊvəleɪɪŋ] 美 ['oʊvəleɪɪŋ]

v. 

Adding borders to your images 图像增加边框

evaluate

英 [ɪ'væljʊeɪt]
美 [ɪˈvæljuˌet]

vt.   

vi.

boundary

生词本
去背诵
英 ['baʊndrɪ]
美 [ˈbaʊndəri, -dri]

n.  

explore   英 [ɪk'splɔ:(r)] 美 [ɪkˈsplɔr]

vi.  

vt.

value = Scalar( rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255) );这句话可以随机的显示色彩

Sobel Derivatives

derivative英 [dɪˈrɪvətɪv]

美 [dɪˈrɪvətɪv]

n.  

adj.  

applicative

生词本
英 ['æplɪkeɪtɪv]
美 ['æpləˌkeɪtɪv]

adj.

approximation

生词本
英 [əˌprɒksɪˈmeɪʃn]
美 [əˌprɑksəˈmeʃən]

n.   

英 ['preznt]
美 [ˈprɛznt]

adj.   

n.  

[priˈzent]

vt.   

vi.

notorious

生词本
去背诵
英 [nəʊ'tɔ:rɪəs]
美 [noʊ'tɔ:rɪrs]

adj.   

You can easily notice that in an edge, the pixel intensity changes in a notorious way. A good way to expresschanges is by using derivatives.A high change in gradient indicates a major change in the image.

graphical

生词本
英 [ˈgræfɪkl]
美 [ˈɡræfɪkl]

adj.

discrete

生词本
英 [dɪˈskri:t]
美 [dɪˈskrit]

adj.  

differentiation

生词本
去背诵
英 [ˌdɪfəˌrenʃɪ'eɪʃn]
美 [ˌdɪfəˌrɛnʃiˈeʃən]

n.   

operator

生词本
去背诵
英 ['ɒpəreɪtə(r)]
美 [ˈɑpəˌretɚ]

n.   

formulation

生词本
去背诵
英 [ˌfɔ:mjʊ'leɪʃn]
美 [ˌfɔrmjəˈleʃən]

n.  

英 [ɒd]
美 [ɑd]

adj.   

n.  

GaussianBlur

Smoothes an image using a Gaussian filter.

C++:  void  GaussianBlur (InputArray  src, OutputArray  dst, Size  ksize, double  sigmaX, double  sigmaY=0, int borderType=BORDER_DEFAULT  )
Python:   cv2. GaussianBlur (src, ksize, sigma1 [, dst [, sigma2 [, borderType ] ] ] ) → dst
Parameters:
  • src – Source image.
  • dst – Destination image of the same size and type as src .
  • ksize – Gaussian kernel size. ksize.width and ksize.height can differ but they both must be positive and odd. Or, they can be zero’s and then they are computed from sigma* .
  • sigmaX – Gaussian kernel standard deviation in X direction.
  • sigmaY – Gaussian kernel standard deviation in Y direction. If sigmaY is zero, it is set to be equal to sigmaX . If both sigmas are zeros, they are computed from ksize.width and ksize.height , respectively. See getGaussianKernel() for details. To fully control the result regardless of possible future modifications of all this semantics, it is recommended to specify all of ksize ,sigmaX , and sigmaY .
  • borderType – Pixel extrapolation method. See borderInterpolate() for details.

The function convolves the source image with the specified Gaussian kernel. In-place filtering is supported.

Sobel

Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.

C++:  void  Sobel (InputArray  src, OutputArray  dst, int  ddepth, int  xorder, int  yorder, int  ksize=3, double  scale=1, double  delta=0, int  borderType=BORDER_DEFAULT  )
Python:   cv2. Sobel (src, ddepth, dx, dy [, dst [, ksize [, scale [, delta [, borderType ] ] ] ] ] ) → dst
C:  void  cvSobel (const CvArr*  src, CvArr*  dst, int  xorder, int  yorder, int  apertureSize=3  )
Python:   cv. Sobel (src, dst, xorder, yorder, apertureSize=3 ) → None
Parameters:
  • src – Source image.
  • dst – Destination image of the same size and the same number of channels as src .
  • ddepth – Destination image depth.
  • xorder – Order of the derivative x.
  • yorder – Order of the derivative y.
  • ksize – Size of the extended Sobel kernel. It must be 1, 3, 5, or 7.
  • scale – Optional scale factor for the computed derivative values. By default, no scaling is applied. See getDerivKernels() for details.
  • delta – Optional delta value that is added to the results prior to storing them in dst .
  • borderType – Pixel extrapolation method. See borderInterpolate() for details.

In all cases except one, the \texttt{ksize} \times\texttt{ksize} separable kernel is used to calculate the derivative. When \texttt{ksize = 1} , the 3 \times 1 or 1 \times 3 kernel is used (that is, no Gaussian smoothing is done). ksize = 1 can only be used for the first or the second x- or y- derivatives.

There is also the special value ksize = CV_SCHARR (-1) that corresponds to the 3\times3 Scharr filter that may give more accurate results than the 3\times3 Sobel. The Scharr aperture is

\vecthreethree{-3}{0}{3}{-10}{0}{10}{-3}{0}{3}

for the x-derivative, or transposed for the y-derivative.

The function calculates an image derivative by convolving the image with the appropriate kernel:

\texttt{dst} =  \frac{\partial^{xorder+yorder} \texttt{src}}{\partial x^{xorder} \partial y^{yorder}}

The Sobel operators combine Gaussian smoothing and differentiation, so the result is more or less resistant to the noise. Most often, the function is called with ( xorder = 1, yorder = 0, ksize = 3) or ( xorder = 0, yorder = 1, ksize = 3) to calculate the first x- or y- image derivative. The first case corresponds to a kernel of:

\vecthreethree{-1}{0}{1}{-2}{0}{2}{-1}{0}{1}

The second case corresponds to a kernel of:

\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}

See also

 

Scharr()Laplacian()sepFilter2D()filter2D()GaussianBlur()

convertScaleAbs

Scales, computes absolute values, and converts the result to 8-bit.

C++:  void  convertScaleAbs (InputArray  src, OutputArray  dst, double  alpha=1, double  beta=0 )
Python:   cv2. convertScaleAbs (src [, dst [, alpha [, beta ] ] ] ) → dst
C:  void  cvConvertScaleAbs (const CvArr*  src, CvArr*  dst, double  scale=1, double  shift=0 )
Python:   cv. ConvertScaleAbs (src, dst, scale=1.0, shift=0.0 ) → None
Parameters:
  • src – Source array.
  • dst – Destination array.
  • alpha – Optional scale factor.
  • beta – Optional delta added to the scaled values.

On each element of the input array, the function convertScaleAbs performs three operations sequentially: scaling, taking an absolute value, conversion to an unsigned 8-bit type:

\texttt{dst} (I)= \texttt{saturate\_cast<uchar>} (| \texttt{src} (I)* \texttt{alpha} +  \texttt{beta} |)

In case of multi-channel arrays, the function processes each channel independently. When the output is not 8-bit, the operation can be emulated by calling the Mat::convertTo method (or by using matrix expressions) and then by computing an absolute value of the result. For example:

Mat_<float> A(30,30);
randu(A, Scalar(-100), Scalar(100));
Mat_<float> B = A*5 + 3;
B = abs(B);
// Mat_<float> B = abs(A*5+3) will also do the job,
// but it will allocate a temporary matrix

See also

 

Mat::convertTo()abs()

addWeighted

Computes the weighted sum of two arrays.

C++:  void  addWeighted (InputArray  src1, double  alpha, InputArray  src2, double  beta, double  gamma, OutputArray  dst, int  dtype=-1 )
Python:   cv2. addWeighted (src1, alpha, src2, beta, gamma [, dst [, dtype ] ] ) → dst
C:  void  cvAddWeighted (const CvArr*  src1, double  alpha, const CvArr*  src2, double  beta, double  gamma, CvArr*  dst )
Python:   cv. AddWeighted (src1, alpha, src2, beta, gamma, dst ) → None
Parameters:
  • src1 – First source array.
  • alpha – Weight for the first array elements.
  • src2 – Second source array of the same size and channel number as src1 .
  • beta – Weight for the second array elements.
  • dst – Destination array that has the same size and number of channels as the input arrays.
  • gamma – Scalar added to each sum.
  • dtype – Optional depth of the destination array. When both input arrays have the same depth, dtypecan be set to -1, which will be equivalent to src1.depth().

The function addWeighted calculates the weighted sum of two arrays as follows:

\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I)* \texttt{alpha} +  \texttt{src2} (I)* \texttt{beta} +  \texttt{gamma} )

where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each channel is processed independently.

The function can be replaced with a matrix expression:

dst = src1*alpha + src2*beta + gamma;

See also

 

add()subtract()scaleAdd()Mat::convertTo()Matrix Expressions


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值