sightmachine / SimpleCV

The Open Source Framework for Machine Vision
http://simplecv.org
BSD 3-Clause "New" or "Revised" License
2.68k stars 798 forks source link

Added Support for automatic port change when image is streamed to browser. #619

Open ghost opened 10 years ago

ghost commented 10 years ago

When using browser display by calling img.show(type="browser") a JpegStreamer server is opened at a fixed port number of 8080. When this port is used by another server, an error is raised to reflect the fact that the port is already in use.

[Errno 98] Address already in use

To Replicate:

ipython notebook --port=8080
simplecv
>>> i = Image('lenna')
>>> i.show(type = 'browser')

Fix: The streamer is switched to adjacent port if the current port is busy. [ ipython like behaviour]

Implementation: A global variable _port holds the current port number ( at start - 8080 ) Using try except block the exception is caught, the port number is incremented ( till port 8090 max ) and streamer initialization is tried again from the current port.

-repo has been pulled from sksavant's fork to build upon the bug fix #617 [ commit #169e090 ] since both these issues are related.

sksavant commented 10 years ago

Added your commit, Fixed typo in #618 and some more changes in Stream.py to deal with jpgdata not filled in.

ghost commented 10 years ago

@sksavant:

Thats cool ... need to fix one more typo and code ... typo: line 6201-> till 8090

fix: do a _port increment before the while loop so that one unnecessary iteration is avoided inside the loop ( js = ... )

Will do that and push it in some time ... and one more thing, why can't we combine pull req #618 and #619 into one ... I dont know how to do it tho .. Do you know it ? or @xamox can u help us out ?

sksavant commented 10 years ago

I pulled the above commit into my branch so it is now added to #618 . I don't think we can combine PRs.

ghost commented 10 years ago

ok

On Tue, Feb 25, 2014 at 3:11 AM, Savant Krishna notifications@github.comwrote:

I pulled the above commit into my branch so it is now added to #618https://github.com/sightmachine/SimpleCV/pull/618. I don't think we can combine PRs.

Reply to this email directly or view it on GitHubhttps://github.com/sightmachine/SimpleCV/pull/619#issuecomment-35942617 .

Raghav Rv