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

  • Home
  • SEARCH
  • 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 8486693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:01:14+00:00 2026-06-10T21:01:14+00:00

I am writing a program in Python, that reads the YV12 Frame data from

  • 0

I am writing a program in Python, that reads the YV12 Frame data from a IP Camera produced by Hikvision Ltd.

In the SDK, they provided a functional call that allows me to setup a Callback to retrieve the Frame Data.

My Callback function is like this:

def py_fDecodeCallBack(lPort, pBuffer, lSize, pFrameInfo, lReserved1, lReserved2):
    print "lPort: %r" % lPort
    print "lSize: %r   " % lSize
    print pFrameInfo
    print pBuffer
    print "pFrame Info: %r   " % pFrameInfo.nWidth

    return 0

$
The structure of pFramInfo is defined like this:

class FRAME_INFO(Structure):
        _fields_ =[
                   ('nWidth', c_long),
                   ('nHeight', c_long),
                   ('nStamp', c_long),
                   ('nType', c_long),
                   ('nFrameRate', c_long),
                   ('dwFrameNum', wintypes.DWORD)
                   ]

$

I use the following code to setup the callback function:

FSETDECCALLBACK = WINFUNCTYPE(c_bool, c_long, POINTER(wintypes.BYTE), c_long, POINTER(FRAME_INFO), c_long, c_long)
fSetDecCallBack = FSETDECCALLBACK(py_fDecodeCallBack)    

Then the callback function is being called by the SDK and it prints out the following:

Traceback (most recent call last):
  File "_ctypes/callbacks.c", line 313, in 'calling callback function'
lPort: 0
lSize: 1382400   
<mytypes.LP_FRAME_INFO object at 0x03109CB0>
<wintypes2.LP_c_byte object at 0x03109D00>
  File "C:\Users\Rex\workspace\iSentry\hcnetsdkhelper.py", line 76, in py_fDecodeCallBack
    print "pFrame Info: %r   " % pFrameInfo.nWidth
AttributeError: 'LP_FRAME_INFO' object has no attribute 'nWidth'

Simple types like c_long (lPort and lSize) are being read correctly, but the pFrameInfo Structure does not have the fields that I have defined. I cannot read pFrameInfo.nWidth as it saids there is no such attribute…

My question is:
How can I read the attributes in the structure returned from the dll through ctypes. I cannot see any examples on google doing this, and I found a topic in python.org http://bugs.python.org/issue5710 saying this just cannot be done, but the message is written in 2009.

I believe that as pFrameInfo is already being read from the dll, is there any way that I can get back the c_long data stored in the pFrameInfo Structure by cutting and reading the bytes in the memory space of pFrameInfo? Since all attributes of pFrameInfo are c_long, may be reading the structure byte by byte can reconstruct the value of the c_long variables. I am just guessing. Please help, this is a really big problem for me…

  • 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-10T21:01:15+00:00Added an answer on June 10, 2026 at 9:01 pm

    I think you need to dereference your pointer to FRAME_INFO:

    frameInfo = pFrameInfo.contents
    ...
    print "pFrame Info: %r   " % frameInfo.nWidth
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a function for my Clojure program that reads user input from
I am writing a basic program in Python that prompts the user to enter
I'm writing a python program that uses scons to build an .exe and then
I am writing a python program that lauches a subprocess (using Popen). I am
I'm writing a program in python that uses genetic techniques to optimize expressions. Constructing
I'm writing a python program that will spawn a subprocess to basically clone a
I'm writing a personal wiki-style program in Python that stores text files in a
I'm writing a Python program that logs terminal interaction (similar to the script program),
I have a problem: I am writing a program in Python 3.2 that requires
I am writing a simple Python program. My program seems to suffer from linear

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.