Hardly a Qt question: you want to use Win32 API to receive data and send it to OpenCV. Here are some thoughts anyway:
Line 3 seems unlikely to be correct. LPCWSTR means "long pointer constant wide string" and you are providing a pointer to a const narrow string. A simple C-style cast does not convert the data, it just silences the compiler error. A wide-string literal looks like L"COM1" or you might use the _T("COM1") macro.
Before you can pass data to OpenCV it needs to be in some format OpenCV will accept, dictated by the sender, and you need to known when the received data is complete. As with network communication you cannot assume the file is received all at once, and readable in one hit, even if it was sent in one write. You must therefore buffer the received data until such time as the data is complete, which generally means you need some way to know the length of the image data.
Line 33 does not make a lot of sense if the data is a binary (image) and not a nul-terminated text string.
Bookmarks