Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8175519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:48:43+00:00 2026-06-06T22:48:43+00:00

I have a program that saves an image in a local directory and then

  • 0

I have a program that saves an image in a local directory and then reads the image from that directory.

But I dont want to save the image. I want to read it directly from the url.

Here’s my code:

import cv2.cv as cv
import urllib2

url = "http://cache2.allpostersimages.com/p/LRG/18/1847/M5G8D00Z/posters/curious-cat.jpg"
filename = "my_test_image" + url[-4:]
print filename
opener = urllib2.build_opener()

page = opener.open(url) 
img= page.read()

abc = open(filename, "wb")
abc.write(img)
abc.close()

img = cv.LoadImage(filename)

cv.ShowImage("Optical Flow", img)
cv.WaitKey(30)

If i change it to:

img = cv.LoadImage(img)

This will give me this error:

argument 1 must be string without null bytes, not str

What can I do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T22:48:46+00:00Added an answer on June 6, 2026 at 10:48 pm

    If you want you can use PIL.

    import cv2.cv as cv
    import urllib2
    from cStringIO import StringIO
    import PIL.Image as pil
    url="some_url"
    
    img_file = urllib2.urlopen(url)
    im = StringIO(img_file.read())
    source = pil.open(im).convert("RGB")
    bitmap = cv.CreateImageHeader(source.size, cv.IPL_DEPTH_8U, 3)
    cv.SetData(bitmap, source.tostring())
    cv.CvtColor(bitmap, bitmap, cv.CV_RGB2BGR)
    

    I guess by this method you don’t need to save the image file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that saves images, but when I debug it I get
I have program that runs fast enough. I want to see the number of
I have a program that downloads PCM data from a Web Server, which it
I have a program that is been implemented in C++ which I now want
I have a program that convert image file to binary and also it converts
I have a high-resolution image that I want to use as a tiled map
I want to save image data to my sqlite database but I can't do
I have following problem: In my titanium project I save an image ( from
I have program that saves unique images that are related to unique database fields
I have program that has a variable that should never change. However, somehow, it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.