You Are Here:

Community: Developer Discussion Boards

#1 Old incomplete upload - 2006-03-15, 22:17

Join Date: Mar 2006
Posts: 29
MrKikkeli's Avatar
MrKikkeli
Offline
Registered User
Hello all,

I am currently developping for fun a "mobile webcam" in python, ie basically I am uploading a picture every 60 seconds to a server.

So far everything goes well, excepted for the fact that the picture that I send seems to reach only partially my server.
As you can see:
mobile webcam
The jpeg file is incomplete most of the time.

I've tried my python code on my computer's interpreter ( I only had to remove the "pys60 only" part, mostly GUI ) and there's no problem with the upload.

Is there a problem with my phone ? ( a Nokia 6680 ) Or is it a problem with the ISP parameters ? is there a way I can check what's wrong for sure ? And most important, how can I fix it !!

here's the python code I use ( the most relevant parts according to me ):
Code:
def post_image(cell_id, key, nom_fichier, contenu):
    BOUNDARY = '-------------UhUhUh------'
    CRLF = '\r\n'
    L = []
    L.append('--' + BOUNDARY)
    L.append('Content-Disposition: form-data; name="cellid"')
    L.append('')
    L.append(cell_id)
    L.append('--' + BOUNDARY)
    L.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (key, nom_fichier))
    L.append('Content-Type: image/jpeg')
    L.append('')
    L.append(contenu)
    L.append( '--' + BOUNDARY + '--' )
    L.append('')
    body = CRLF.join(L)
    content_type = 'multipart/form-data; boundary=%s' % BOUNDARY
    conn = httplib.HTTPConnection("pangcentury.free.fr")
    conn.putrequest('POST', '/mobileWebcam/mobileWebcam.php')
    conn.putheader('content-type', content_type)
    conn.putheader('content-length', str(len(body)))
    conn.endheaders()
    conn.send(body)
and

Code:
def run():
    global running, img, total_bytes_sent, max_bytes, direction, white_bal, expos, fl, IMEI
    while running and total_bytes_sent < max_bytes:
        if int( sysinfo.battery() ) < 2:
            logging(u"Attention, batterie trop faible !\nL'application va se terminer.")
            running = 0
        else:
            params = { 'mode':'RGB16', 'size': (640,480),
                       'flash':fl, 'zoom':0, 'exposure': expos,
                       'white_balance':white_bal, 'position':0
                       }
            img = apply(camera.take_photo, (), params)
            img = img.resize((160,120), keepaspect = 1 )
            if direction != '':
                img = img.transpose(direction)
            img.save("E:\\Images\\mobileWebcam.jpg")
            cellid = location.gsm_location()[3]
            cell_id = str(cellid)
            taille = os.path.getsize("E:\\Images\\mobileWebcam.jpg")
            fichier = open("E:\\Images\\mobileWebcam.jpg", 'rb')
            try:
                post_image(cell_id, 'image', 'nokia6680.jpg', fichier.read())
                total_bytes_sent += int(taille)
                truc = total_bytes_sent / 1024
                truc2 = unicode(truc)
                truc2 += u" ko envoyés au total"
                logging(truc2)
                countdown(60)
            except:
                logging(u"erreur dans l'envoi du fichier" )
                running = 0
            fichier.close()
    if total_bytes_sent > max_bytes:
        logging(u"maximum d'upload autorisé atteint." )
Oh and while I am at it, here's a likely bug I stumbled upon while coding this: it seems like you can't use the flash in camera.take_photo() if the picture size is (160,120). That's why I have to take the picture first in (640,480) and resize it.
Reply With Quote

#2 Old Re: incomplete upload - 2006-03-15, 22:37

Join Date: Aug 2004
Posts: 290
simo.salminen
Offline
Regular Contributor
I've heard there is probs with http post when using wap gateway.
Reply With Quote

#3 Old Re: incomplete upload - 2006-03-16, 00:31

Join Date: Mar 2006
Posts: 29
MrKikkeli's Avatar
MrKikkeli
Offline
Registered User
is there a workaround?
Reply With Quote

#4 Old Re: incomplete upload - 2006-03-16, 11:43

Join Date: Aug 2004
Posts: 290
simo.salminen
Offline
Regular Contributor
Use "normal" internet access point.What kind of access points name you have in the selection dialog?
Reply With Quote

#5 Old Re: incomplete upload - 2006-03-16, 22:42

Join Date: Mar 2006
Posts: 29
MrKikkeli's Avatar
MrKikkeli
Offline
Registered User
Wap, Gprs and a third one the "nokia setting wizard" set up by himself. I haven't checked the details of this one yet.

so far, from my own experience, the wap access was the less reliable. GPRS was better, and now it seems that the 3rd one works okay, according to the last picture I uploaded ( meet my dog ! ).

I'll try again tomorrow while hanging out in Paris and I'll keep you informed.

Edit : it doesn't seem to make a difference at all
Last edited by MrKikkeli : 2006-03-17 at 00:45.
Reply With Quote

#6 Old Re: incomplete upload - 2006-04-12, 17:04

Join Date: Nov 2004
Posts: 105
rexwal
Offline
Regular Contributor
Hi MrKikkeli! Can I just ask you a quick question if its possible? Just wondering how you manage to post an image from python to the web?

How do you manage to add the image data into the http request because that seems really really cool!
Reply With Quote

#7 Old Re: incomplete upload - 2006-04-12, 17:41

Join Date: Aug 2004
Posts: 290
simo.salminen
Offline
Regular Contributor
rexwal, the original post has the code (post_image method).
Reply With Quote

#8 Old Post Re: incomplete upload - 2006-04-12, 18:12

Join Date: Feb 2006
Posts: 23
aymanshamma
Offline
Registered User
rexwal,

I have a small tutorial online on how to do HTTP Posts of text and binary data as well as multipart form data, from a PyS60 device via php/apache.

http://aymanshamma.googlepages.com/h...frompys60tophp

Includes all the py sample code as well as the php scripts to accept the requests.

-a.
Reply With Quote

#9 Old Re: incomplete upload - 2006-04-13, 12:42

Join Date: Mar 2006
Posts: 29
MrKikkeli's Avatar
MrKikkeli
Offline
Registered User
if you ever use my code or aymanshamma's code, I am very curious to hear about it, especially if you manage to receive complete pictures on the server side.
Reply With Quote

#10 Old Re: incomplete upload - 2006-04-13, 12:48

Join Date: Nov 2004
Posts: 105
rexwal
Offline
Regular Contributor
Well, I was doing something else completely.. and it did work .. I used part's of your code and mobile lenin's code.. it wasn't to do with sending over http, but over sockets to a j2me app running on the phone.. and it's working pretty well to date
Reply With Quote

#11 Old Re: incomplete upload - 2006-04-13, 13:10

Join Date: Feb 2005
Posts: 1,353
Location: Belgium (Europe)
cyke64's Avatar
cyke64
Offline
Super Contributor
hello ,

mobil lenine code ? Could you show me the link to get it ?
Is it available to public ?


pys60 1.4.5,1.9.7,pygame,PyS60 CE on E90 , N810 with Python 2.5.2 and ... last PyS60 1.9.7 with touch ui on 5800 !

pys60 extension modules on http://cyke64.googlepages.com/
Reply With Quote

#12 Old Re: incomplete upload - 2006-04-13, 14:42

Join Date: Aug 2004
Posts: 290
simo.salminen
Offline
Regular Contributor
aymanshamma, nice tutorial. Additional tip: it is good to use multipart/form-data because (usually) server allows to upload bigger files with that method.
Reply With Quote

#13 Old Smile Re: incomplete upload - 2006-04-13, 18:52

Join Date: Feb 2006
Posts: 23
aymanshamma
Offline
Registered User
Thanks simo -- I'll add your tip to my little website.

Cheers,

-a.
Reply With Quote

#14 Old Re: incomplete upload - 2006-04-18, 12:40

Join Date: Nov 2004
Posts: 105
rexwal
Offline
Regular Contributor
http://www.mobilenin.com/pys60/menu.htm <- link to mobile lenin code
Reply With Quote

#15 Old Re: incomplete upload - 2006-04-24, 03:26

Join Date: Mar 2006
Posts: 29
MrKikkeli's Avatar
MrKikkeli
Offline
Registered User
I am done with my "mobile Webcam": the code works, well at least does what I expect it to do, so I thought I'd share it with you:
http://mattsstuff.free.fr/dotclear/i...1-mobilewebcam

I hope it'll be useful, or that at least you can have as much fun with this as I have
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Where can I upload an Appication? Borriez General Discussion 0 2005-09-20 16:36
Upload Image Problem!!! ckeddie General Browsing 4 2005-01-26 07:58
upload J2ME app onto Java phones mzichao Mobile Java General 1 2005-01-11 08:11
Linux driver in RedHat 7.3 nsolhjoo Multimodecards 0 2003-10-24 18:04
image upload incomplete SkyRaVeR Digital Rights Management & Content Downloading 0 2003-06-02 23:48

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia