谁用.net做过视频采集的 进来看看 急啊!!!!!!!!!!

czsd 2003-08-21 09:19:26
我是用海康威视DS-400xM系列卡系统SDK 来做视频检测系统的 期间在调用其中一个方法
int StartVideoPreview(HANDLE hChannelHandle,HWND WndHandle, RECT *rect, BOOLEAN bOverlay, int VideoFormat, int FrameRate); 用来打开视频预览 始终 没有看到图象 而检查它的返回值 却没有错误

我是用DLLImport方法导入这个方法的
[DllImport("tmSDK.dll")]
static extern int StartVideoPreview(int hChannelHandle,int WndHandle, ref RECT rect, bool bOverlay, int VideoFormat, int FrameRate);

其中RECT 我也重新用
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public long left;
public long top;
public long right;
public long bottom;
}
定义了下 总是显示不出图象 不知道怎么回事 请各位看看 帮帮忙 谢谢了

...全文
51 23 打赏 收藏 转发到动态 举报
写回复
用AI写文章
23 条回复
切换为时间正序
请发表友善的回复…
发表回复
czsd 2003-08-25
  • 打赏
  • 举报
回复
好象还是不行哦
我把这个dll接口及其说明抄给大家看看

int StartVideoPreview(HANDLE hChannelHandle,HWND WndHandle, RECT *rect, BOOLEAN bOverlay, int VideoFormat, int FrameRate);
参数: HANDLE hChannelHandle 通道句柄 HWND WndHandle, 窗口句柄 RECT *rect, 窗口内的矩型区域 BOOLEAN bOverlay, 打开或关闭Overlay模式预览 int VideoFormat, 视频格式(见2.1节) int FrameRate 视频帧率 说明: 启动视频预览, 如果在VideoFormat 中设置为YUV类型,则系统中的显示卡必须支持硬件Overlay功能,显示卡的颜色必须为16位色或32位色;如果VideoFormat设置为RGB类型,则采用DDRAW模式显示,即视频窗口会覆盖所有位于窗口范围内的图像; 返回: 正确为0, 其他为第1节定义的错误号;
czsd 2003-08-21
  • 打赏
  • 举报
回复
是不是这样写
using System.Reflection;
[DllImport("tmSDK.dll")]
static extern int StartVideoPreview( IntPtr hChannelHandle,IntPtr WndHandle, Pointer rect,
bool bOverlay, int VideoFormat, int FrameRate);
qimini 2003-08-21
  • 打赏
  • 举报
回复
Box 把非托管类型的指针转换为托管类型的对象(Pointer)
UnBox 与Box相反
qimini 2003-08-21
  • 打赏
  • 举报
回复
From MSDN:

-------------
Provides a wrapper class for pointers.

For a list of all members of this type, see Pointer Members.

System.Object
System.Reflection.Pointer


[CLSCompliant(false)]
public sealed class Pointer : ISerializable

--------------
And for more detail ,you can refer to MSDN about Pointer.Box(..) and Pointer.UnBox(...)
czsd 2003-08-21
  • 打赏
  • 举报
回复
能不能给出函数的定义给我看看 要在unsafe里吗 怎么用 能详细点吗
qimini 2003-08-21
  • 打赏
  • 举报
回复
Pointer(unsafe C#)
czsd 2003-08-21
  • 打赏
  • 举报
回复
谢谢 楼上的 兄弟
在问句 你说指针不是用ref 那用什么 呢?
qimini 2003-08-21
  • 打赏
  • 举报
回复
static extern int StartVideoPreview(int hChannelHandle,int WndHandle, ref RECT rect, bool bOverlay, int VideoFormat, int FrameRate);<<<<<<<<<<<<<<<<<<<
这里申明错误。WIN32 API中的HANDLE类型和HWND类型是和C#中的IntPtr类型对应的,不是int。另外API中的指针在C#(unsafe)中是和IntPtr.ToPointer();对应的。


Hope it would help you !


czsd 2003-08-21
  • 打赏
  • 举报
回复
函数返回值是对的 是0 符合 它的说明
下面是我实际调用的代码
int xx=hkVideo.startVideoPreview( y,this.Handle.ToInt32() ,ref z,false, HkVideo.vdfRGB16 , 25 );
FengLinXp 2003-08-21
  • 打赏
  • 举报
回复
你先看一下函数返回值是不是正确
FengLinXp 2003-08-21
  • 打赏
  • 举报
回复
你函数实际调用的代码呢?贴出来一块看看
luoyangture 2003-08-21
  • 打赏
  • 举报
回复
gz
Jinniu 2003-08-21
  • 打赏
  • 举报
回复
关注,有解决办法了请告诉我。谢谢!
cfq421@163.com
维她奶 2003-08-21
  • 打赏
  • 举报
回复
up & gz
qimini 2003-08-21
  • 打赏
  • 举报
回复
static extern int StartVideoPreview(int hChannelHandle,int WndHandle, ref RECT rect, bool bOverlay, int VideoFormat, int FrameRate);>>>
static extern int StartVideoPreview(IntPtr hChannelHandle,IntPtr WndHandle, ref RECT rect,bool bOverlay, int VideoFormat, int FrameRate);

估计是类型不匹配
rouser 2003-08-21
  • 打赏
  • 举报
回复
呵呵,我要是有時間就去搞搞視頻開發
挺有意思的也
SolidGL 2003-08-21
  • 打赏
  • 举报
回复
这个问题不是很好搞吧?
czsd 2003-08-21
  • 打赏
  • 举报
回复
先自己顶下 来者均有分
qimini 2003-08-21
  • 打赏
  • 举报
回复
A sample From dy630(半导体)
>>>>>>
int GetVideoPosition(
[Out, MarshalAs(UnmanagedType.LPStruct)] out RECT lpSRCRect,
[Out, MarshalAs(UnmanagedType.LPStruct)] out RECT lpDSTRect
);
>>>>>>API Definetion>>>>>
HRESULT GetVideoPosition(
RECT *pSourceRect,
RECT *pDestinationRect
);

qimini 2003-08-21
  • 打赏
  • 举报
回复
struct is a valuetype,declare the parameters [in] or [out] can help you when you work with WIN32 API.

using System.Reflection;
[DllImport("tmSDK.dll")]
static extern int StartVideoPreview( IntPtr hChannelHandle,IntPtr WndHandle, [out,in] RECT rect,bool bOverlay, int VideoFormat, int FrameRate);

<---------OR--------->

using System.Reflection;
[DllImport("tmSDK.dll")]
static extern int StartVideoPreview( IntPtr hChannelHandle,IntPtr WndHandle, [out] RECT rect,bool bOverlay, int VideoFormat, int FrameRate);
加载更多回复(3)

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧