Ask Your Question

smhall05's profile - activity

2020-02-04 20:51:48 -0600 received badge  Famous Question (source)
2017-08-17 07:05:06 -0600 received badge  Famous Question (source)
2016-11-11 20:07:06 -0600 received badge  Notable Question (source)
2015-11-15 13:52:48 -0600 received badge  Notable Question (source)
2015-06-29 11:27:52 -0600 received badge  Popular Question (source)
2015-02-05 07:46:21 -0600 received badge  Popular Question (source)
2013-09-09 15:52:38 -0600 commented answer cv2.imread a url

@berak @jayrambhia Using network protocols without global network initialization. Please use avformat_network_init(), this will become mandatory later.

The code that is triggering this is below. If I pass in a local jpeg it is clean, when I pas in a url of the jpeg, I get the above.

link = sys.argv[1] cap = cv2.VideoCapture(link) if( cap.isOpened() ): ret, im = cap.read()

Any ideas how to clean this up?

2013-09-06 19:35:40 -0600 received badge  Supporter (source)
2013-09-06 19:35:37 -0600 received badge  Scholar (source)
2013-09-06 15:19:11 -0600 commented answer numpy.ndarray returning incorrect pixel value vs pixelaccess type

Thank you, I actually started looking at that a few minutes ago and noticed when I swapped my x,y to y,x I got what I expected with numpy.ndarray. Now to make sense of this in my full program and make the swap!

2013-09-06 13:40:26 -0600 asked a question numpy.ndarray returning incorrect pixel value vs pixelaccess type

I am confused as to why opencv is returning the incorrect BGR value when given a pixel location, x,y.

BGR color space:

When I request x = 12, y = 5 I get back 147, 147, 147 when the image type is of numpy.ndarray

When I request x = 12, y = 5 I get back 238, 235, 235 of type PixelAccess.

I expect BGR(238,235,235) or RGB(235,235,238) to be the correct answer. Below I have a code snippet that returns the incorrect then the correct pixel values after converting numpy to pixelaccess. The image under test is also attached. Thank you for any help.

C:\fakepath\incorrect_color_values_returned.png

Questions:

1) What subtlety am I missing/overlooking here w.r.t numpy.ndarrays?

2) Is it possible to get numpy.ndarray to return the correct value without having to convert to PixelAccess?

3) What is the correct way to access numpy.ndarray x,y values?

Here is my code (I use videocapture intentionally to handle images from a url)

from PIL import Image
import cv2
cap = cv2.VideoCapture("incorrect_color_values_returned.png")
ret, im = cap.read()

print type(im)
print im[12,5]
im = cv2.cvtColor(im,cv2.COLOR_BGR2RGB)
pil_im = Image.fromarray(im)
pix = pil_im.load()
print type(pix)
print pix[12,5]
2013-07-10 21:18:12 -0600 commented answer cv2.imread a url

Can you provide an example of how it is done? Maybe I can utilize that snippet of code instead of importing SimpleCV.

2013-07-10 17:48:28 -0600 asked a question Python cleaning up avformat_network_init() message

How do I go about cleaning up:

Using network protocols without global network initialization. Please use avformat_network_init(), this will become mandatory later.

The code that is triggering this is below. If I pass in a local jpeg it is clean, when I pas in a url of the jpeg, I get the above.

link = sys.argv[1] cap = cv2.VideoCapture(link) if( cap.isOpened() ): ret, im = cap.read()

Questions:

1) What can I do to clean up this warning message, processing the image from the url quickly is of high importance and I suspect I am killing performance with this message. There are about 10 messages in a row of the same text. Thank you.

2013-07-09 10:08:09 -0600 commented answer cv2.imread a url

Actually I forgot to comment out the from SimpleCV import Image line. When I did that, the speeds are comparable. If I already have the image local and use cv2.imread, I get 200ms back when processing the image. My goal is to get pretty close to that.

Not sure what they are doing, guess I have some homework!

2013-07-09 09:24:12 -0600 commented answer cv2.imread a url

Thanks that works, but it is slower than using:

from SimpleCV import Image img = Image("http://example.com/someimage.jpg")

For one thing I am getting the below warnings:

Using network protocols without global network initialization. Please use avformat_network_init(), this will become mandatory later.

Looking it up now, thought I'd post here in parallel.

2013-07-08 23:21:09 -0600 asked a question cv2.imread a url

How can I read an image from a url with cv2.imread? I am able to do it with SimpleCV, but it is rather bulky just to do an image read.

I would like to achieve something like:

im = cv2.imread("http://example.com/someimage.jpg")

2013-05-02 23:44:31 -0600 asked a question How do I remove all but one color in an image (Python)?

In GIMP I am able to do the following:

Tools -> Selection Tools -> By Color Select (Shift+O)

Click on the single color I want to keep

Select -> Invert (Shift+I)

Edit -> Clear (Delete)

This allows me to remove all but the one color I clicked on. How can I do this in Python with opencv?