Open Mv face_detection over wifi

OpenMV related project discussion.
MANASH
Posts: 14
Joined: Tue Dec 25, 2018 4:36 pm

Open Mv face_detection over wifi

Postby MANASH » Thu Jan 03, 2019 3:14 pm

Hi,
i am doing a project on face detection over wifi streaming.Faces are being detected in the ide but not in the browser over wifi. Please help me out in this.i am attaching my code .

Code: Select all

# MJPEG Streaming AP.
# This example shows off how to do MJPEG streaming in AccessPoint mode.
# Chrome, Firefox and MJpegViewer App on Android have been tested.
# Connect to OPENMV_AP and use this URL: http://192.168.1.1:8080 to view the stream.

import sensor, image, time, network, usocket, sys

SSID ='OPENMV_AP'    # Network SSID
KEY  ='1234567890'    # Network key (must be 10 chars)
HOST = ''           # Use first available interface
PORT = 8080         # Arbitrary non-privileged port

# Reset sensor
sensor.reset()

# Set sensor settings
sensor.set_contrast(1)
sensor.set_brightness(1)
sensor.set_saturation(1)
sensor.set_gainceiling(16)
sensor.set_framesize(sensor.QQVGA)
sensor.set_pixformat(sensor.RGB565)

# Load Haar Cascade
# By default this will use all stages, lower satges is faster but less accurate.
face_cascade = image.HaarCascade("frontalface", stages=25)
print(face_cascade)

# Init wlan module in AP mode.
wlan = network.WINC(mode=network.WINC.MODE_AP)
wlan.start_ap(SSID, key=KEY, security=wlan.WEP, channel=2)

# You can block waiting for client to connect
#print(wlan.wait_for_sta(10000))

def start_streaming(s):
    print ('Waiting for connections..')
    client, addr = s.accept()
    # set client socket timeout to 2s
    client.settimeout(2.0)
    print ('Connected to ' + addr[0] + ':' + str(addr[1]))

    # Read request from client
    data = client.recv(1024)
    # Should parse client request here
MANASH
Posts: 14
Joined: Tue Dec 25, 2018 4:36 pm

Re: Open Mv face_detection over wifi

Postby MANASH » Thu Jan 03, 2019 3:22 pm

I am unable to upload the complete code..
MANASH
Posts: 14
Joined: Tue Dec 25, 2018 4:36 pm

Re: Open Mv face_detection over wifi

Postby MANASH » Thu Jan 03, 2019 3:28 pm

This is the code.. Please guide me to solve this. I am kind of beginner in networking and socket programming.
Attachments
openmv forum.txt
It's the code... Please check and guide me..
(3.16 KiB) Downloaded 77 times
User avatar
kwagyeman
Posts: 2993
Joined: Sun May 24, 2015 2:10 pm

Re: Open Mv face_detection over wifi

Postby kwagyeman » Thu Jan 03, 2019 11:11 pm

Hi, Ibrahim will be able to help you in a bit.
Nyamekye,
MANASH
Posts: 14
Joined: Tue Dec 25, 2018 4:36 pm

Re: Open Mv face_detection over wifi

Postby MANASH » Fri Jan 04, 2019 4:11 am

Thank you, waiting for your help..
User avatar
kwagyeman
Posts: 2993
Joined: Sun May 24, 2015 2:10 pm

Re: Open Mv face_detection over wifi

Postby kwagyeman » Fri Jan 04, 2019 12:08 pm

Um, yeah, so, what are you trying to do and what exactly is wrong? You didn't specify what actually isn't working. You just posted some code with no indication what you are trying to communicate with.
Nyamekye,
MANASH
Posts: 14
Joined: Tue Dec 25, 2018 4:36 pm

Re: Open Mv face_detection over wifi

Postby MANASH » Fri Jan 04, 2019 3:39 pm

Actually I am trying to view the detected faces over wifi. But, unsuccessful.. I am not being able to send the faces through the socket.. The video is being transmitted, but face detection is not.. I have tried by changing the socket to a Tcp socket. But, I am not getting the idea that how to send the algorithm " for r in objects
Img.draw_rectangle(r)" over wifi.. This is where I am stucked. Please help me out. I am trying for a long period and I have been through many videos and tutorials but unsuccessful...
User avatar
kwagyeman
Posts: 2993
Joined: Sun May 24, 2015 2:10 pm

Re: Open Mv face_detection over wifi

Postby kwagyeman » Sat Jan 05, 2019 12:32 pm

Hi, you haven't described what application is receiving your data. A socket has to connect to some device and send the data to it. If you want to do a WiFi based application you need to think about what will receive the data and clearly define a protocol for that reception.
Nyamekye,
User avatar
iabdalkader
Posts: 803
Joined: Sun May 24, 2015 3:53 pm

Re: Open Mv face_detection over wifi

Postby iabdalkader » Sat Jan 05, 2019 8:03 pm

MANASH wrote:
Fri Jan 04, 2019 3:39 pm
Actually I am trying to view the detected faces over wifi. But, unsuccessful.. I am not being able to send the faces through the socket.. The video is being transmitted, but face detection is not.. I have tried by changing the socket to a Tcp socket. But, I am not getting the idea that how to send the algorithm " for r in objects
Img.draw_rectangle(r)" over wifi.. This is where I am stucked. Please help me out. I am trying for a long period and I have been through many videos and tutorials but unsuccessful...
You draw after compressing the image, try moving compressed() after drawing.
MANASH
Posts: 14
Joined: Tue Dec 25, 2018 4:36 pm

Re: Open Mv face_detection over wifi

Postby MANASH » Sun Jan 06, 2019 5:52 am

iabdalkader wrote:
Sat Jan 05, 2019 8:03 pm
MANASH wrote:
Fri Jan 04, 2019 3:39 pm
Actually I am trying to view the detected faces over wifi. But, unsuccessful.. I am not being able to send the faces through the socket.. The video is being transmitted, but face detection is not.. I have tried by changing the socket to a Tcp socket. But, I am not getting the idea that how to send the algorithm " for r in objects
Img.draw_rectangle(r)" over wifi.. This is where I am stucked. Please help me out. I am trying for a long period and I have been through many videos and tutorials but unsuccessful...
You draw after compressing the image, try moving compressed() after drawing.
Hello sir,
I have tried, but we can't draw after compression.. Rest of the code is working well, but I need to pack the draw_rectangle algorithm so that we can send it to wifi socket using client.send().
MANASH
Posts: 14
Joined: Tue Dec 25, 2018 4:36 pm

Re: Open Mv face_detection over wifi

Postby MANASH » Sun Jan 06, 2019 5:56 am

kwagyeman wrote:
Sat Jan 05, 2019 12:32 pm
Hi, you haven't described what application is receiving your data. A socket has to connect to some device and send the data to it. If you want to do a WiFi based application you need to think about what will receive the data and clearly define a protocol for that reception.
I have created the socket and the whole function to send and rechive the data.
Attachments
openmv forum.txt
Please ckeck this and suggest me if it is wrong and where the mistake is exactly.
(3.16 KiB) Downloaded 69 times
MANASH
Posts: 14
Joined: Tue Dec 25, 2018 4:36 pm

Re: Open Mv face_detection over wifi

Postby MANASH » Sun Jan 06, 2019 9:17 am

kwagyeman wrote:
Sat Jan 05, 2019 12:32 pm
Hi, you haven't described what application is receiving your data. A socket has to connect to some device and send the data to it. If you want to do a WiFi based application you need to think about what will receive the data and clearly define a protocol for that reception.
Hello sir,
We are viewing the video in a chrome browser. And we will try to see the video in a mjpeg video streaming app.
User avatar
iabdalkader
Posts: 803
Joined: Sun May 24, 2015 3:53 pm

Re: Open Mv face_detection over wifi

Postby iabdalkader » Sun Jan 06, 2019 11:00 am

Hello sir,
I have tried, but we can't draw after compression..
You draw after compression, so you send the image before drawing, you should draw *before* compression. It's not that hard really, just do this:

Code: Select all

        for r in objects:
           img.draw_rectangle(r)
        cframe = img.compressed(quality=35)   
MANASH
Posts: 14
Joined: Tue Dec 25, 2018 4:36 pm

Re: Open Mv face_detection over wifi

Postby MANASH » Mon Jan 07, 2019 1:18 pm

iabdalkader wrote:
Sun Jan 06, 2019 11:00 am
Hello sir,
I have tried, but we can't draw after compression..
You draw after compression, so you send the image before drawing, you should draw *before* compression. It's not that hard really, just do this:

Code: Select all

        for r in objects:
           img.draw_rectangle(r)
        cframe = img.compressed(quality=35)   
Thank you so much sir. It is working...

Return to “Project Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests