chenxiaoqino / udp-image-streaming Goto Github PK
View Code? Open in Web Editor NEWCompress and stream live images over UDP protocol with OpenCV
Compress and stream live images over UDP protocol with OpenCV
Hello chenxiaoqino,
I want to use your code in a new project (credit will be given) but i have problem with the configurations, do you have a summery of all the VS configurations changes need to be done for running the code or something like this? it will be very helpful.
Thank you!
ron
Hi Chen Xiaoqino,
I was referred to your conversion of Richard's udp image streaming video.
I'm creating an issue because i don't know what your email address is.
A few questions:
-How is the latency
-Does it do both unicast and multicast, and does it use opencv for that or does it use separate network code. I see multicast references but the server doesn't seem to have any arguments other then port.
-If it's all the same to you, would you mind changing the license to a MIT license? I would like to use this (and will credit you) but with the GPL ambigous legal terms i'd rather not use that in my other code.
Thanks a lot.
atv2016
What changes would have to be made to the code to allow for multicasting?
I noticed when i start a server on one pc, and a client on the other, the client will setup a camera as if it is a server itself. It won't actually receive the server feed. It works fine on the same pc.
I'll have to experiment with this a bit more but it seems to not completely work as it should yet.
Hi everyone
please I have a question regarding video savage at the client level, that it is sent from a server. You can tell me which lines of code to add or which tool you used, if possible.
Hi, I am trying your solution to stream OpenCV processed images from one computer to another. However, I am stuck at the build step. It seems the VS compiler is not able to link the functions in TCPServerSocket. No issue during the cmake. I tried to modify the CMakeLists.txt to explicitly include the header files, but it does not work. Strangely, I am able to build the project in Ubuntu. The attached is the error log from VS 2017.
PracticalSocket.obj : error LNK2019: unresolved external symbol accept referenced in function "public: class TCPSocket * __cdecl TCPServerSocket::accept(void)" (?accept@TCPServerSocket@@QEAAPEAVTCPSocket@@xz)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol bind referenced in function "public: void __cdecl Socket::setLocalPort(unsigned short)" (?setLocalPort@Socket@@QEAAXG@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol closesocket referenced in function "public: __cdecl Socket::~Socket(void)" (??1Socket@@qeaa@XZ)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol connect referenced in function "public: void __cdecl CommunicatingSocket::connect(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,unsigned short)" (?connect@CommunicatingSocket@@QEAAXAEBV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@g@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol getpeername referenced in function "public: class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl CommunicatingSocket::getForeignAddress(void)" (?getForeignAddress@CommunicatingSocket@@qeaa?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@xz)
3>Generating Code...
2>PracticalSocket.obj : error LNK2019: unresolved external symbol getsockname referenced in function "public: class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl Socket::getLocalAddress(void)" (?getLocalAddress@Socket@@qeaa?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@xz)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol htonl referenced in function "public: void __cdecl Socket::setLocalPort(unsigned short)" (?setLocalPort@Socket@@QEAAXG@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol htons referenced in function "public: void __cdecl Socket::setLocalPort(unsigned short)" (?setLocalPort@Socket@@QEAAXG@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol inet_addr referenced in function "public: void __cdecl UDPSocket::joinGroup(class std::basic_string<char,struct std::char_traits,class std::allocator > const &)" (?joinGroup@UDPSocket@@QEAAXAEBV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@@z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol inet_ntoa referenced in function "public: class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl Socket::getLocalAddress(void)" (?getLocalAddress@Socket@@qeaa?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@xz)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol listen referenced in function "private: void __cdecl TCPServerSocket::setListen(int)" (?setListen@TCPServerSocket@@AEAAXH@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol ntohs referenced in function "public: unsigned short __cdecl Socket::getLocalPort(void)" (?getLocalPort@Socket@@QEAAGXZ)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol recv referenced in function "public: int __cdecl CommunicatingSocket::recv(void *,int)" (?recv@CommunicatingSocket@@QEAAHPEAXH@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol recvfrom referenced in function "public: int __cdecl UDPSocket::recvFrom(void *,int,class std::basic_string<char,struct std::char_traits,class std::allocator > &,unsigned short &)" (?recvFrom@UDPSocket@@QEAAHPEAXHAEAV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@aeag@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol send referenced in function "public: void __cdecl CommunicatingSocket::send(void const *,int)" (?send@CommunicatingSocket@@QEAAXPEBXH@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol sendto referenced in function "public: void __cdecl UDPSocket::sendTo(void const *,int,class std::basic_string<char,struct std::char_traits,class std::allocator > const &,unsigned short)" (?sendTo@UDPSocket@@QEAAXPEBXHAEBV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@g@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol setsockopt referenced in function "public: void __cdecl UDPSocket::setMulticastTTL(unsigned char)" (?setMulticastTTL@UDPSocket@@QEAAXE@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol socket referenced in function "protected: __cdecl Socket::Socket(int,int)" (??0Socket@@iEAA@HH@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol gethostbyname referenced in function "void __cdecl fillAddr(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,unsigned short,struct sockaddr_in &)" (?fillAddr@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@GAEAUsockaddr_in@@@z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol getservbyname referenced in function "public: static unsigned short __cdecl Socket::resolveService(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,class std::basic_string<char,struct std::char_traits,class std::allocator > const &)" (?resolveService@Socket@@SAGAEBV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@0@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol WSAStartup referenced in function "protected: __cdecl Socket::Socket(int,int)" (??0Socket@@iEAA@HH@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol WSACleanup referenced in function "public: static void __cdecl Socket::cleanUp(void)" (?cleanUp@Socket@@Saxxz)
I'm trying to stream from one computer to another but keep receiving the unexpected size pack. Using my pc as the client and my laptop as the server, I get will get messages like this:
expecting length of packs:19
Received unexpected size pack:4
Received unexpected size pack:4
Received unexpected size pack:4
Received packet from 192.168.1.2:42113
Corrupt JPEG data: premature end of data segment
Doing the opposite configuration with the pc as the server and my laptop as the client, I do not receive this error.
Could the webcam on the pc be sending too much data to the laptop? If so, how can the code be changed to account for this?
How to use over two PCs?
Hello, I get the following error when I try to make the demo:
rehofman@Reto-Ubuntu:~/UDPStream/udp-image-streaming$ cmake . && make
-- Configuring done
-- Generating done
-- Build files have been written to: /home/rehofman/UDPStream/udp-image-streaming
[ 25%] Building CXX object CMakeFiles/client.dir/PracticalSocket.cpp.o
/home/rehofman/UDPStream/udp-image-streaming/PracticalSocket.cpp: In constructor ‘SocketException::SocketException(const string&, bool)’:
/home/rehofman/UDPStream/udp-image-streaming/PracticalSocket.cpp:50:38: error: ‘strerror’ was not declared in this scope
userMessage.append(strerror(errno));
^
/home/rehofman/UDPStream/udp-image-streaming/PracticalSocket.cpp: In function ‘void fillAddr(const string&, short unsigned int, sockaddr_in&)’:
/home/rehofman/UDPStream/udp-image-streaming/PracticalSocket.cpp:64:32: error: ‘memset’ was not declared in this scope
memset(&addr, 0, sizeof(addr)); // Zero out address structure
^
/home/rehofman/UDPStream/udp-image-streaming/PracticalSocket.cpp: In member function ‘void Socket::setLocalPort(short unsigned int)’:
/home/rehofman/UDPStream/udp-image-streaming/PracticalSocket.cpp:136:42: error: ‘memset’ was not declared in this scope
memset(&localAddr, 0, sizeof(localAddr));
^
/home/rehofman/UDPStream/udp-image-streaming/PracticalSocket.cpp: In member function ‘void UDPSocket::disconnect()’:
/home/rehofman/UDPStream/udp-image-streaming/PracticalSocket.cpp:308:40: error: ‘memset’ was not declared in this scope
memset(&nullAddr, 0, sizeof(nullAddr));
^
make[2]: *** [CMakeFiles/client.dir/PracticalSocket.cpp.o] Error 1
make[1]: *** [CMakeFiles/client.dir/all] Error 2
make: *** [all] Error 2
What am I doing wrong?
I have tried to run the same program in two different machines. Client in one PC and server program in another PC. However it doesnt work. Does this program support multiple PCs? If so, what modification is required. Tried below trial.
In PC1:
Client 192.168.12 9999
In PC2:
Server 9999 (No response)
Hey there!
Is there a way I can have the client forward the packets received from the server to a new client (the first client may behave as a server to this client)? Like port forwarding..
Something like A to B to C and that video is played at C and not B. Is there any suggestions that you can give? Not sure which command can do this work in sockets.
Thanks!! :D
After running it for a long time, the client crashed with the following:
13291 effective FPS:67.8564 kbps:6514.22
OpenCV Error: Assertion failed (ssize.area() > 0) in resize, file /tmp/opencv20160107-29960-t5glvv/opencv-2.4.12/modules/imgproc/src/imgwarp.cpp, line 1968
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /tmp/opencv20160107-29960-t5glvv/opencv-2.4.12/modules/imgproc/src/imgwarp.cpp:1968: error: (-215) ssize.area() > 0 in function resize
14737Abort trap: 6
I saw some google reports that this might be because the frame or image was empty:
http://stackoverflow.com/questions/21581858/c-opencv-assertion-failed-in-resize
Found when trying to build the source code that if you're on a mac and you have version 4 of opencv that you need to remove and use version 3 such as
brew install opencv@3
brew unlink opencv
brew link opencv@3
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.