Click here to Skip to main content
15,307,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to stream a webcam feed from a python server using cv2 video capture to a c# ,the client connects to the server without a problem but nothing shows on the pictureEdit(devexpress pictureEdit control);

What I have tried:

This is my Python server:
Python
import socket

import cv2
import imutils

server_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
host_name  = socket.gethostname()
host_ip = socket.gethostbyname(host_name)
print('HOST IP:',host_ip)
port = 9999
socket_address = (host_ip,port)
server_socket.bind(socket_address)
server_socket.listen(5)
print("LISTENING AT:",socket_address)
while True:
    client_socket, addr = server_socket.accept()
    print('GOT CONNECTION FROM:', addr)
    if client_socket:
        vid = cv2.VideoCapture(0)

        while (vid.isOpened()):
            img, frame = vid.read()
            ret, buffer = cv2.imencode('.jpg', frame)

            file = open("image.jpg",'br')
            #a = pickle.dumps(frame)
            #message = struct.pack("Q", len(a)) + a

            client_socket.sendall(frame)

            #cv2.imshow('TRANSMITTING VIDEO', frame)
            key = cv2.waitKey(1) & 0xFF
            if key == ord('q'):
                client_socket.close()

And this is my client side code:
C#
private void startFeed()
       {
           // Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
           //IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse("192.168.1.6"), 9999);
           TcpClient socket = new TcpClient();
           socket.Connect("192.168.1.6",9999);
           while (true)
           {
               try {
               NetworkStream stream = socket.GetStream();
               byte[] bytes = new byte[socket.ReceiveBufferSize];
                   stream.Read(bytes, 0,bytes.Length) ;

               //socket.Receive(bytes);
               pictureEdit1.EditValue = bytes;
               }catch(Exception e)
               {
                   Console.WriteLine(e);
               }
           }
       }
Posted
Comments
Gerry Schmitz 29-Apr-21 18:41pm
   
So this is actually a "DevExpress control not working" question.
hado25 29-Apr-21 19:36pm
   
no devexpress pictureEdit allows me to read images directy as a byte[]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900