Results 1 to 9 of 9

Thread: Qt application with live Active X camera feed.

  1. #1
    Join Date
    Jan 2006
    Posts
    70
    Thanks
    13
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Qt application with live Active X camera feed.

    I could really use some advice. I’m using Qt 4.1 and trying to implement an Active X control.

    Here is a link to the Active X – AxisMediaControl SDK
    http://www.axis.com/techsup/cam_servers/dev/activex.htm

    In the SDK they have sample software using this Active X app through the MFC library, which I’ve noticed that the wrapper they wrote inherits a class called CWnd and calls a function named “InvokeHelper” for all of it’s control of the Active X component. This gives me no signs that a COM object exists for this app.

    This is what I did and it doesn’t seem to work:

    // ---------------------------------------------------------
    QAxWidget* axis = new QAxWidget(this);

    // this control id was verified and is correct
    axis->setControl(QString::fromUtf8(“{745395C8-D0E1-4227-8586-624CA9A10A8D}”));
    axis->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    axis->setObjectName(QString::fromUtf8(“AxisMediaC ontrol”));

    // setup the MediaURL
    axis->dynamicCall(“InvokeHelper(0x1, 0x4, 0, 0, “”\x0E””, http://dizco.com:81/axis-cgi/mjpg/video.cgi)”);

    // setup the MediaType
    axis->dynamicCall(“InvokeHelper(0x1, 0x4, 0, 0, “”\x0E””, mjpeg-unicast)”);

    // press Play
    axis->dynamicCall(“InvokeHelper(0x65, 0x1, 0, 0, 0, 0);
    // ---------------------------------------------------------

    NOTE: If you decide to download the Active X control and run the sample Visual C++ project provided by them, go to the MJPEGunicastDlg.cpp and change the media URL to the one above and you can see the live camera feed work.

    Any help you may be able to give me on using this Active X app in my Qt application would be much appreciated.
    Thank you.

  2. #2
    Join Date
    Jan 2006
    Posts
    70
    Thanks
    13
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt application with live Active X camera feed.

    I've changed my code to look more like the Qt documentation in hopes that someone might recognize what i am doing wrong.

    I'm guessing the InvokeHelper is not what i should be calling.
    Here's some info on the method:

    Call this member function to invoke the ActiveX Control method or property specified by dwDispID, in the context specified by wFlags.

    void AFX_CDECL InvokeHelper(
    DISPID dwDispID,
    WORD wFlags,
    VARTYPE vtRet,
    void* pvRet,
    const BYTE* pbParamInfo,
    ...
    );
    Parameters
    dwDispID
    Identifies the method or property to be invoked.
    wFlags
    Flags describing the context of the call to IDispatch::Invoke. For possible wFlags values, see IDispatch::Invoke in the Platform SDK.
    vtRet
    Specifies the type of the return value. For possible values, see the Remarks section for COleDispatchDriver::InvokeHelper.
    pvRet
    Address of the variable that will that will receive the property value or return value. It must match the type specified by vtRet.
    pbParamInfo
    Pointer to a null-terminated string of bytes specifying the types of the parameters following pbParamInfo. For possible values, see the Remarks section for COleDispatchDriver::InvokeHelper.
    ...
    Variable List of parameters, of types specified in pbParamInfo.



    //-------------------------------------------------
    axis = new QAxWidget();
    axis->setControl(QString::fromUtf8("{745395C8-D0E1-4227-8586-624CA9A10A8D}"));
    axis->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    axis->setObjectName(QString::fromUtf8("AxisMediaControl "));

    QList<QVariant> params;
    params << 0x1;
    params << 0x4;
    params << 0;
    params << 0;
    params << "\x0E";
    params << "http://dizco.com:81/axis-cgi/mjpg/video.cgi";
    axis->dynamicCall("InvokeHelper(int, uint, uint, QString, QString)", params);

    QList<QVariant> params2;
    params2 << 0x9;
    params2 << 0x4;
    params2 << 0;
    params2 << 0;
    params2 << "\x0E";
    params2 << "mjpeg-unicast";
    axis->dynamicCall("InvokeHelper(int, uint, uint, QString, QString)", params2);

    QList<QVariant> params3;
    params3 << 0x65;
    params3 << 0x1;
    params3 << 0;
    params3 << 0;
    params3 << 0;
    axis->dynamicCall("InvokeHelper(int, uint, uint, QString, QString)", params3);

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt application with live Active X camera feed.

    Quote Originally Posted by bitChanger
    I'm guessing the InvokeHelper is not what i should be calling.
    I looks more like a wrapper that just invokes methods of that COM object. Is there any specification of interfaces implemented by that AxisMediaControl object in the docs?

    PS. Note that you have a space after object name in axis->setObjectName(...) line.

  4. #4
    Join Date
    Jan 2006
    Posts
    70
    Thanks
    13
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt application with live Active X camera feed.

    I now have a solution for my problem and would like to share with anyone interested.

    dynamicCall was not the answer in this case since the COM object interface uses types that are unknown to Qt.

    So the solution was to use queryInterface to get a pointer to the IDispatch handle and call invoke directly. Which by the way turns out to be the low level call made by MFC's invokeHelper method. So in stepping through the debugger on the MFC sample provided by Axis, I was able to make up a quick and dirty call in Qt to accually get this to work. Now I will clean it up and create my own Qt wrapper class for this Active X control and all will be well.

    If your interested in trying this out, it's really quite a neat trick. Here is the ugly quick and dirty way of just getting a live feed to work in a Qt Application.

    #include <afxwin.h>
    #include <OleAuto.h>

    axis = new QAxWidget();
    axis->setControl(QString::fromUtf8("{745395C8-D0E1-4227-8586-624CA9A10A8D}"));
    axis->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    axis->setObjectName(QString::fromUtf8("CAxisMediaContro l"));

    EXCEPINFO excepInfo;
    memset(&excepInfo, 0, sizeof excepInfo);

    UINT nArgErr = (UINT)-1; // initialize to invalid arg

    DISPPARAMS dispparams;
    memset(&dispparams, 0, sizeof dispparams);
    dispparams.cArgs = 1;
    dispparams.cNamedArgs = 1;
    DISPID dispidNamed = DISPID_PROPERTYPUT;
    dispparams.rgdispidNamedArgs = &dispidNamed;
    VARIANT* pArg = new VARIANT[dispparams.cArgs];
    dispparams.rgvarg = pArg;
    memset(pArg, 0, sizeof(VARIANT) * dispparams.cArgs);
    pArg->vt = 8;
    pArg->bstrVal = _T("http://dizco.com:81/axis-cgi/mjpg/video.cgi");

    IDispatch *iface = 0;
    axis->queryInterface(QUuid(IID_IDispatch), (void**)&iface);
    if (iface) {
    iface->Invoke(1, IID_NULL, 0, 4, &dispparams, 0, &excepInfo, &nArgErr);
    pArg->bstrVal = _T("mjpeg-unicast");
    iface->Invoke(9, IID_NULL, 0, 4, &dispparams, 0, &excepInfo, &nArgErr);
    dispparams.cArgs = 0;
    dispparams.cNamedArgs = 0;
    dispparams.rgdispidNamedArgs = 0;
    dispparams.rgvarg = 0;
    iface->Invoke(101, IID_NULL, 0, 1, &dispparams, 0, &excepInfo, &nArgErr);

    iface->Release();

  5. #5
    Join Date
    Jan 2006
    Location
    Houston, TX
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt application with live Active X camera feed.

    If possible, please post the rest of the code to your solution.

    Thanks,

    David

  6. #6
    Join Date
    Jan 2006
    Posts
    70
    Thanks
    13
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt application with live Active X camera feed.

    This should be all the code you would need. Just create a basic Qt app with a custom widget. Then place the above code in the constructor for the widget.

  7. #7
    Join Date
    Sep 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt application with live Active X camera feed.

    Hi, I know the last message for this thread was in 2006, but I try !

    I want to do exactly the same thing. So I have created a new widget which has a QAxWidget. Here is the constructor code of my new widget class :

    Qt Code:
    1. AxisMediaControlWidget::AxisMediaControlWidget(QWidget *parent, Qt::WFlags flags)
    2. : QWidget(parent, flags)
    3. {
    4. m_axis = new QAxWidget(this);
    5. m_glay = new QGridLayout(this);
    6.  
    7. m_axis->setControl(QString::fromUtf8("{745395C8-D0E1-4227-8586-624CA9A10A8D}"));
    8. m_axis->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    9. m_axis->setObjectName(QString::fromUtf8("CAxismediacontrol"));
    10.  
    11. EXCEPINFO excepInfo;
    12. memset(&excepInfo, 0, sizeof excepInfo);
    13.  
    14. UINT nArgErr = (UINT)-1; // initialize to invalid arg
    15.  
    16. DISPPARAMS dispparams;
    17. memset(&dispparams, 0, sizeof dispparams);
    18. dispparams.cArgs = 1;
    19. dispparams.cNamedArgs = 1;
    20. DISPID dispidNamed = DISPID_PROPERTYPUT;
    21. dispparams.rgdispidNamedArgs = &dispidNamed;
    22. VARIANT* pArg = new VARIANT[dispparams.cArgs];
    23. dispparams.rgvarg = pArg;
    24. memset(pArg, 0, sizeof(VARIANT) * dispparams.cArgs);
    25.  
    26. IDispatch *iface = 0;
    27. m_axis->queryInterface((QUuid)IID_IDispatch, (void**)&iface);
    28. if (iface)
    29. {
    30. pArg->vt = VT_EMPTY;
    31. dispparams.cArgs = 0;
    32. dispparams.cNamedArgs = 0;
    33. iface->Invoke(102, IID_NULL, 0, DISPATCH_METHOD, &dispparams, 0, &excepInfo, &nArgErr);
    34.  
    35. dispparams.cArgs = 1;
    36. dispparams.cNamedArgs = 1;
    37. // put_PTZControlURL
    38. pArg->bstrVal = (L"http://10.67.148.30/axis-cgi/com/ptz.cgi");
    39. iface->Invoke(0x1e, IID_NULL, 0, DISPATCH_PROPERTYPUT, &dispparams, 0, &excepInfo, &nArgErr);
    40.  
    41. // put_UIMode
    42. pArg->bstrVal = _T("ptz-absolute");
    43. iface->Invoke(0x3, IID_NULL, 0, DISPATCH_PROPERTYPUT, &dispparams, 0, &excepInfo, &nArgErr);
    44.  
    45. pArg->vt = VT_BOOL;
    46. pArg->boolVal = VARIANT_TRUE;
    47. iface->Invoke(0x12, IID_NULL, 0, DISPATCH_PROPERTYPUT, &dispparams, 0, &excepInfo, &nArgErr);
    48.  
    49. iface->Invoke(0x11, IID_NULL, 0, DISPATCH_PROPERTYPUT, &dispparams, 0, &excepInfo, &nArgErr);
    50.  
    51. iface->Invoke(0x10, IID_NULL, 0, DISPATCH_PROPERTYPUT, &dispparams, 0, &excepInfo, &nArgErr);
    52.  
    53. iface->Invoke(0x73, IID_NULL, 0, DISPATCH_PROPERTYPUT, &dispparams, 0, &excepInfo, &nArgErr);
    54.  
    55. iface->Invoke(0x75, IID_NULL, 0, DISPATCH_PROPERTYPUT, &dispparams, 0, &excepInfo, &nArgErr);
    56.  
    57. pArg->vt = VT_BSTR;
    58. pArg->bstrVal = (L"default,+ptz");
    59. iface->Invoke(0x13, IID_NULL, 0, DISPATCH_PROPERTYPUT, &dispparams, 0, &excepInfo, &nArgErr);
    60.  
    61. pArg->bstrVal = (L"http://10.67.148.30/axis-cgi/mjpg/video.cgi");
    62. iface->Invoke(1, IID_NULL, 0, DISPATCH_PROPERTYPUT, &dispparams, 0, &excepInfo, &nArgErr);
    63.  
    64. pArg->bstrVal = (L"mjpg");
    65. iface->Invoke(9, IID_NULL, 0, DISPATCH_PROPERTYPUT, &dispparams, 0, &excepInfo, &nArgErr);
    66.  
    67. // Play
    68. pArg->vt = VT_EMPTY;
    69. dispparams.cArgs = 0;
    70. dispparams.cNamedArgs = 0;
    71. dispparams.rgdispidNamedArgs = 0;
    72. dispparams.rgvarg = 0;
    73. iface->Invoke(101, IID_NULL, 0, DISPATCH_METHOD, &dispparams, 0, &excepInfo, &nArgErr);
    74.  
    75. iface->Release();
    76. }
    77. m_glay->addWidget(m_axis, 0, 0);
    78. }
    To copy to clipboard, switch view to plain text mode 

    When I display my new widget in a QDialog, I have the tool bar I want to display but the frame where the video must be displayed stay white.

    Do you have an idea why it doesn't work ?

  8. #8
    Join Date
    Aug 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt application with live Active X camera feed.

    Only for future readers who will find this post from google like me :-) There is more simple way to do it. My code:

    Qt Code:
    1. #include <ActiveQt/qaxwidget.h>
    2. #include <QtGui/qapplication.h>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. w.setControl(QString::fromUtf8("{745395C8-D0E1-4227-8586-624CA9A10A8D}"));
    8. w.setObjectName(QString::fromUtf8("Axis Video"));
    9. w.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    10. w.show();
    11.  
    12. w.dynamicCall("MediaURL", "http://10.0.0.10/axis-cgi/mjpg/video.cgi");
    13. w.dynamicCall("MediaType", "mjpeg-unicast");
    14. w.dynamicCall("StretchToFit", "true");
    15. w.dynamicCall("Play()");
    16. return a.exec();
    17. }
    To copy to clipboard, switch view to plain text mode 

  9. #9
    Join Date
    Sep 2012
    Posts
    1
    Qt products
    PyQt3 PyQt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt application with live Active X camera feed.

    May be this software could help to you, its really awesome http://www.videocapx.com

Similar Threads

  1. Problem with Painter in Qt4.4.1
    By merry in forum Qt Programming
    Replies: 1
    Last Post: 1st September 2008, 13:47

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.