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 8484299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:20:37+00:00 2026-06-10T20:20:37+00:00

I am using Numpy and OpenCV2.4.1, my IP Camera has an SDK that returns

  • 0

I am using Numpy and OpenCV2.4.1, my IP Camera has an SDK that returns the picture buffer through a callback function.
The simplified function is as follows:

def py_fDecodeCallBack(lPort, pBuffer, lSize, pFrameInfo, lReserved1, lReserved2):
    frameInfo = pFrameInfo.contents
    pBufY = np.asarray( pBuffer[:frameInfo.lHeight*frameInfo.lWidth],dtype=np.uint8).reshape(frameInfo.lHeight,frameInfo.lWidth, 1)

$

pBuffer is of POINTER(c_ubyte) type as I am using ctypes.

I try to acquire the Y channel of the pBuffer, which is in YV12 format, and put it into a Numpy Array for OpenCV to process.

However, there is a big bottleneck in np.asarray(), it takes too long to acquire the frame data and put into a 3D numpy array (Height, Width, Channel). I have tested that pointer access operation of pBuffer for slicing the Y data out is not the bottle neck. This callback can only run at 3 frames per second on a dual core computer with 4GB ram. Without the np.asarray() operation, the callback can run at 30 frames per second.

Please suggest a method in order to put the pBuffer Data into a 3D numpy array which is FAST enough to get 30frames per second .

  • 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-10T20:20:38+00:00Added an answer on June 10, 2026 at 8:20 pm

    If you don’t need to copy the data (i.e. your callback will process it and then discard it) you can construct the array using the buffer directly:

    array = (ctypes.c_ubyte * frameInfo.lHeight * frameInfo.lWidth * 1
              ).from_address(ctypes.addressof(pBuffer.contents))
    pBufY = np.ndarray(buffer=array, dtype=np.uint8,
                       shape=(frameInfo.lHeight, frameInfo.lWidth, 1))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Has anyone tried compiling SciPy 0.7.1 on Windows using numpy-1.3.0 that was built with
I've been using Numpy's numpy.random.exponential function for a while. I now see that Python's
I am new to using numpy and one thing that I really don't understand
I created a python .py with some sort methods. I'm using numpy so that
Using numpy, I have this definition of a function: def powellBadlyScaled(X): f1 = 10**4
I'm using numpy.delete to remove elements from an array that is inside a while
I'm trying to apply opencv's Threshold function to a numpy array. I'm using the
I'm using numpy, in particular the histrogram2d function. I am binning a 3D spatial
So, I'm doing some Kmeans classification using numpy arrays that are quite sparse-- lots
Using NumPy , a matrix A has n rows and m columns, and I

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.