a1784544402 2023-04-11 10:33 采纳率: 0%
浏览 75
已结题

天地伟业解码器sdk二次开发

天地伟业解码器sdk二次开发

https://www.likecs.com/show-206201.html

img

我需要用C++实现,但我自己照着C#改也改不好,
应该回调函数这儿出问题了
这我自己一边现学一遍写的,大部分找着sdk的开发手册来的,肯定有问题,不知道怎么搞了

我看了几个老哥的回复,但是都不太沾边啊,我现在的问题是登录不上去,程序调用不了摄像头
我自己判断是回调函数那边有问题,但是我技术不够,解决不了

img

img

img

试了之后是-3一直是未登录

img

登录返回值是0,但是回调函数那边没反应
而且它这返回值是0,还返回一个ID,该怎么接收呢

img

#include<stdio.h>
#include"DecCtrlClient.h"
#include"ActionControl.h"
#include"DecCtrlClientTypes.h"
#include"GlobalTypes.h"
#include"net_sdk_types.h"
#include"RetValue.h"
#include"x_type.h"
#include <iostream>
using namespace std;

int g_iLogonID = -1; 
//主回调
int tMainNotify(unsigned long _lID, unsigned int _uiMsg, unsigned int _iChannel, int _iPos, void* _pvParam, int _iParamSize, void* _pvUserData)
{
    
    switch (_uiMsg)
    {
    case DEC_WCM_DEC_LOGON:
    {
        if (DEC_LOGON_SUCCESS == (int)_pvParam)
        {
            DEC_ClientGetLogonState((int)_lID);
            cout << "登录成功" << endl;
        }
        cout << "登录失败" << endl;
        break;
    }
    case DEC_WCM_ERR_ORDER:
        break;
    case DEC_WCM_DEC_PICSNAP:
        cout << "抓拍" << endl;
        break;
    case DEC_WCM_DEC_GETPICFILENAME:
        break;
        //......
        //......
        //......
    default:
        cout << "未有正确消息值传递进来" << endl;
        break;
    }

    return 0;
}

//参数改变回调函数
int tParaChangeNotify(unsigned long _lID, unsigned int _uiMsg, unsigned int _iChannel, int _iPos, void* _pvParam, int _iParamSize, void* _pvUserData)
{
    switch (_uiMsg)
    {
    case DEC_PARACHANGE_ENCODERPAPA:
        break;
        //......
        //......
        //......
    default:
        cout << "未有消息值传递进来" << endl;
        break;
    }

    return 0;
}


/*
int PrintScreen() {

    int iRet = -1;
    ServerItem tServerItem = { 0 };
    tServerItem.iSize = sizeof(ServerItem);
    PicSnap Sp = {0};
    Sp.uServerItem = tServerItem;
    //iRet = DEC_ClientSendCommand(g_iLogonID,0,0, DEC_COMMAND_PICSNAP, Sp,1024);
    
}
*/

int main() {

    //初始化
    DEC_ClientStartup(0,NULL);
    
    //设置回调函数
    DecNotifyFun tDecNotifyFun = { 0 };
    tDecNotifyFun.iSize = sizeof(DecNotifyFun);
    tDecNotifyFun.pMainNotify = tMainNotify;
    tDecNotifyFun.pParamChangeNotify = tParaChangeNotify;
    DEC_ClientSetNotify(&tDecNotifyFun);
    
    //登录设备
    g_iLogonID = DEC_ClientLogon("192.168.1.2", "Admin", "1111", 3000);
    if (g_iLogonID < 0)
    {
        cout << g_iLogonID << endl;
        OutputDebugString("Logon failed!\n");
    }

    //抓拍
    cout << "****************" << endl;
    
    //注销登录
    DEC_ClientLogout(g_iLogonID);
    //释放SDK资源
    DEC_ClientCleanup();

    return 0;
}

  • 写回答

4条回答 默认 最新

  • 何宝荣love 2023-04-11 11:05
    关注

    以下是一个简单的示例代码,用于使用天地伟业解码器sdk进行解码:

    #include <iostream>
    #include "TDWDecoder.h"
    
    int main() {
        // 创建解码器
        TDWDecoder decoder;
    
        // 打开视频文件
        if (!decoder.open("test.mp4")) {
            std::cerr << "Failed to open video file!" << std::endl;
            return -1;
        }
    
        // 获取视频信息
        int width = decoder.getWidth();
        int height = decoder.getHeight();
        int fps = decoder.getFPS();
        int frameCount = decoder.getFrameCount();
        std::cout << "Video Info: " << width << "x" << height << ", " << fps << "fps, " << frameCount << " frames" << std::endl;
    
        // 解码视频帧
        for (int i = 0; i < frameCount; i++) {
            // 获取下一帧
            cv::Mat frame;
            if (!decoder.read(frame)) {
                std::cerr << "Failed to read frame " << i << "!" << std::endl;
                break;
            }
    
            // 显示帧
            cv::imshow("Frame", frame);
            cv::waitKey(1);
        }
    
        // 关闭解码器
        decoder.release();
    
        return 0;
    }
    

    在这个示例中,我们首先创建了一个TDWDecoder对象,然后使用open()函数打开了一个名为"test.mp4"的视频文件。然后我们通过getWidth()、getHeight()、getFPS()和getFrameCount()函数获取了视频的一些基本信息,并将其打印到控制台上。接着我们使用read()函数逐帧读取视频,然后使用imshow()函数显示每一帧。最后我们使用release()函数释放解码器对象。

    请注意,这只是一个简单的示例代码,你需要根据你的具体需求进行修改和扩展。

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 4月18日
  • 修改了问题 4月12日
  • 赞助了问题酬金15元 4月11日
  • 修改了问题 4月11日
  • 展开全部