EasyPlayerPro Windows播放器电子放大/局部放大播放功能实现
背景描述
在视频监控软件中,我们看到很多的软件都有电子放大功能, 按住鼠标左键不放,框选一个区域,再松开鼠标左键,即对选中的区域进行放大显示, 且可以重复该操作,逐步放大所需显示的区域, 有没有觉得,这个功能在视频监控软件中还是有他的用武地. 今天我们就来实现该功能;
实现流程
//设置电子放大起起始点
int SetElectronicZoomStartPoint(int channelId, float fXPercent, float fYPercent, unsigned char showBox);
//设置电子放大结束点(在鼠标移动过程中可一直调用该函数)
int SetElectronicZoomEndPoint(int channelId, float fXPercent, float fYPercent);
//设置是否放大显示
int SetElectronicZoom(int channelId, int zoomIn);
//复位
void ResetElectronicZoom(int channelId);
//直接设置显示区域,用于电子放大, 在某些场合, 需要直接进行缩放显示, 即可调用该函数实现
int SetRenderRect(int channelId, LPRECT lpSrcRect);
代码实现
int ChannelManager::ElectronicZoomProcess(MEDIA_VIDEO_CHANNEL_OBJ_T *pMediaChannel, EASY_FRAME_INFO *frameInfo)
{
if (NULL == pMediaChannel) return 0;
if (NULL == frameInfo) return 0;
ELECTRONIC_ZOOM_T *pElectoricZoom = pMediaChannel->pElectoricZoom;
if (NULL == pElectoricZoom) return 0;
int nLeft = 0, nTop = 0, nRight = 0, nBottom = 0;
if (pElectoricZoom->zoomIn >= 0x01)
{
RECT rcClient;
GetClientRect(pMediaChannel->mediaDisplay.hWnd, &rcClient);
float fLeftPercent = pElectoricZoom->fStartPointX;
float fTopPercent = pElectoricZoom->fStartPointY;
float fRightPercent = pElectoricZoom->fEndPointX;
float fBottomPercent = pElectoricZoom->fEndPointY;
if (fRightPercent > fLeftPercent && fBottomPercent > fTopPercent) //逐步放大
{
if (pElectoricZoom->fVideoWidth > 0)
{
int video_width = (int)pElectoricZoom->fVideoWidth;
int video_height= (int)pElectoricZoom->fVideoHeight;
nLeft = (int)((float)video_width / 100.0f * fLeftPercent);
nTop = (int)((float)video_height/ 100.0f * fTopPercent);
nRight = (int)((float)video_width / 100.0f * fRightPercent);
nBottom = (int)((float)video_height/ 100.0f * fBottomPercent);
if (nRight > nLeft && nBottom > nTop)
{
pElectoricZoom->fVideoWidth = (float)(nRight - nLeft);
pElectoricZoom->fVideoHeight = (float)(nBottom - nTop);
nLeft = pElectoricZoom->startVideoLeft + nLeft;
nTop = pElectoricZoom->startVideoTop + nTop;
nRight = pElectoricZoom->startVideoLeft + nRight;
nBottom = pElectoricZoom->startVideoTop + nBottom;
pElectoricZoom->startVideoLeft = nLeft;
pElectoricZoom->startVideoTop = nTop;
if (pElectoricZoom->zoomIndex + 1 <MAX_ZOOM_IN_TIMES)
{
SetRect(&pElectoricZoom->zoomParam[pElectoricZoom->zoomIndex].rect, nLeft, nTop, nRight, nBottom);
pElectoricZoom->zoomParam[pElectoricZoom->zoomIndex].fVideoWidth = pElectoricZoom->fVideoWidth;
pElectoricZoom->zoomParam[pElectoricZoom->zoomIndex].fVideoHeight = pElectoricZoom->fVideoHeight;
pElectoricZoom->zoomParam[pElectoricZoom->zoomIndex].startVideoLeft = pElectoricZoom->startVideoLeft;
pElectoricZoom->zoomParam[pElectoricZoom->zoomIndex].startVideoTop = pElectoricZoom->startVideoTop;
pElectoricZoom->zoomIndex ++;
}
}
else
{
int idx = pElectoricZoom->zoomIndex-2;
if (idx > 0)
{
nLeft = pElectoricZoom->zoomParam[idx].rect.left;
nTop = pElectoricZoom->zoomParam[idx].rect.top;
nRight = pElectoricZoom->zoomParam[idx].rect.right;
nBottom = pElectoricZoom->zoomParam[idx].rect.bottom;
pElectoricZoom->fVideoWidth = pElectoricZoom->zoomParam[idx].fVideoWidth;
pElectoricZoom->fVideoHeight = pElectoricZoom->zoomParam[idx].fVideoHeight;
pElectoricZoom->startVideoLeft = pElectoricZoom->zoomParam[idx].startVideoLeft;
pElectoricZoom->startVideoTop = pElectoricZoom->zoomParam[idx].startVideoTop;
}
}
}
else
{
int video_width = frameInfo->width;
int video_height= frameInfo->height;
nLeft = (int)((float)video_width / 100.0f * fLeftPercent);
nTop = (int)((float)video_height/ 100.0f * fTopPercent);
nRight = (int)((float)video_width / 100.0f * fRightPercent);
nBottom = (int)((float)video_height/ 100.0f * fBottomPercent);
pElectoricZoom->startVideoLeft = nLeft;
pElectoricZoom->startVideoTop = nTop;
pElectoricZoom->fVideoWidth = (float)(nRight - nLeft);
pElectoricZoom->fVideoHeight = (float)(nBottom - nTop);
SetRect(&pElectoricZoom->zoomParam[0].rect, nLeft, nTop, nRight, nBottom);
pElectoricZoom->zoomParam[0].fVideoWidth = pElectoricZoom->fVideoWidth;
pElectoricZoom->zoomParam[0].fVideoHeight = pElectoricZoom->fVideoHeight;
pElectoricZoom->zoomParam[0].startVideoLeft = pElectoricZoom->startVideoLeft;
pElectoricZoom->zoomParam[0].startVideoTop = pElectoricZoom->startVideoTop;
pElectoricZoom->zoomIndex ++;
}
}
else
{
if (pElectoricZoom->zoomIndex > 1)
{
int idx = pElectoricZoom->zoomIndex-2;
nLeft = pElectoricZoom->zoomParam[idx].rect.left;
nTop = pElectoricZoom->zoomParam[idx].rect.top;
nRight = pElectoricZoom->zoomParam[idx].rect.right;
nBottom = pElectoricZoom->zoomParam[idx].rect.bottom;
pElectoricZoom->fVideoWidth = pElectoricZoom->zoomParam[idx].fVideoWidth;
pElectoricZoom->fVideoHeight = pElectoricZoom->zoomParam[idx].fVideoHeight;
pElectoricZoom->startVideoLeft = pElectoricZoom->zoomParam[idx].startVideoLeft;
pElectoricZoom->startVideoTop = pElectoricZoom->zoomParam[idx].startVideoTop;
pElectoricZoom->zoomIndex --;
}
else
{
pElectoricZoom->fVideoWidth = 0.0f;
nLeft = 0;
nTop = 0;
nRight = frameInfo->width;
nBottom = frameInfo->height;
pElectoricZoom->zoomIndex = 0;
}
}
RECT rcSrc;
SetRect(&rcSrc, nLeft, nTop, nRight, nBottom);
CopyRect(&pMediaChannel->mediaDisplay.rcSrcRender, &rcSrc);
pElectoricZoom->zoomIn --;
}
return 0;
}
关于EasyPlayerPro
EasyPlayerPro是一款全功能的流媒体播放器,支持RTSP、RTMP、HTTP、HLS、UDP、RTP、File等多种流媒体协议播放、支持本地文件播放,支持本地抓拍、本地录像、播放旋转、多屏播放、倍数播放等多种功能特性,核心基于ffmpeg,稳定、高效、可靠、可控,支持Windows、Android、iOS三个平台,目前在多家教育、安防、行业型公司,都得到的应用,广受好评!
EasyPlayerPro:https://github.com/EasyDSS/EasyPlayerPro
点击链接加入群【EasyPlayer & EasyPlayerPro】:544917793
技术支持
QQ交流群:544917793
EasyPlayerPro是一款非常稳定的全协议/全功能播放器组件,各平台版本需要经过授权才能商业使用,商业授权方案可以通过以上渠道进行更深入的技术与合作咨询;
获取更多信息
EasyDarwin开源流媒体服务器:www.EasyDarwin.org
EasyDSS商用流媒体解决方案:www.EasyDSS.com
EasyNVR无插件直播方案:www.EasyNVR.com
Copyright © EasyDarwin Team 2012-2017
EasyPlayerPro Windows播放器电子放大/局部放大播放功能实现的更多相关文章
- EasyPlayerPro windows播放器本地音频播放音量控制实现
背景描述 作为一个播放器, 除了能播放视频和声音外,音量控制是绝对不能缺少的功能; 本文在音视频播放的基础上,增加对音量的控制: 实现流程 调用mixerGetDevCaps获取音频输出设备列表; 打 ...
- EasyPlayerPro Windows播放器进行本地对讲喊话音频采集功能实现
需求 在安防行业应用中,除了在本地看到摄像机的视频和进行音频监听外,还有一个重要的功能,那就是对讲. EasyPlayerPro-win为了减轻二次开发者的工作量,将本地音频采集也进行了集成: 功能特 ...
- EasyPlayerPro windows播放器在播放RTMP视频显示重复异常问题解决
问题来源 2017.12.18 今日有杭州某教育领域客户反馈EasyPlayerPro在播放一个rtmp源时,画面显示异常的问题.截图如下: 问题复现 一番思考, 将显示格式改为D3D显示, 正常, ...
- EasyPlayerPro windows播放器本地配置文件配置方法介绍
需求背景 应EasyPlayerPro某客户需求,在EasyPlayerPro启动时,自动播放指定的url源, 不需要每次都去手动填写, 且实现自动播放,不需要手动的单击播放按钮: 为响应该需求,特增 ...
- EasyPlayerPro Windows播放器读取xml配置文件中的特殊字符问题
问题被反馈 今日一客户反馈说播放不了带用户名密码的流, 奇怪,这个问题不存在啊-,按照客户的说法, 是将url地址保存在配置文件中,然后再打开EasyPlayerPro运行: 问题复现 在EasyPl ...
- EasyPlayerPro Windows播放器本地快照抓拍截图功能实现方法
背景描述 作为一个播放器,截图功能必不可少; 下面主要记录一下截图功能的实现: 实现流程 将解码后的帧进行格式转换(目标格式为RGB24); 采用独立的线程进行截图处理; 截图可保存为BMP或JPG两 ...
- EasyPlayerPro Windows播放器全屏模式下GDI显示出现黑屏问题解决
问题来源 2017.12.21 前天有杭州某教育领域客户反馈有部分视频源在全屏模式下显示黑屏: 问题复现 EasyPlayerPro由于没有实现单个窗口完全全屏,故没有暴露该问题,晚上加班,加上单个窗 ...
- EasyPlayerPro Windows播放器实时流进行本地缓冲区即时回放功能实现
背景描述 参照国内视频监控行业监控软件,实现当前视频的即时回放功能,例如: 监控人员发现刚刚的某个视频点有可疑,就像录像回放一样,想倒回去看一下,但又不想切换到录像回放界面, 此处就体现即时回放的价值 ...
- EasyPlayer RTSP Windows播放器D3D,GDI的几种渲染方式的选择区别
EasyPlayer-RTSP windows播放器支持D3D和GDI两种渲染方式,其中D3D支持格式如下: DISPLAY_FORMAT_YV12 DISPLAY_FORMAT_YUY2 DISPL ...
随机推荐
- 删除svn控制
1.用cmd 进去所要删除的目录 2.运行 for /r ./ %a in (./) do @if exist "%a/.svn" rd /s /q "%a/.svn& ...
- SpringBoot第十一篇:SpringBoot+MyBatis+Thymelaf实现CRUD
作者:追梦1819 原文:https://www.cnblogs.com/yanfei1819/p/10936304.html 版权声明:本文为博主原创文章,转载请附上博文链接! 引言 总结前面几 ...
- 最短Hamilton路径
题目描述 给定一张 n(n≤20) 个点的带权无向图,点从 0~n-1 标号,求起点 0 到终点 n-1 的最短Hamilton路径. Hamilton路径的定义是从 0 到 n-1 不重不漏地经过每 ...
- iOS进行单元测试OCUnit+xctool
单元测试 什么是单元测试 wiki解释 简单说来就是为你的方法多专门写一个测试函数.以保证你的方法在不停的修改开发中.保持正确.如果出错,第一时间让你知道,这样从最小单位开始监控来保证软件的质量. 我 ...
- 清理Xcode的技巧和方法
移除对旧设备的支持 影响:可重新生成:再连接旧设备调试时,会重新自动生成.我移除了4.3.2, 5.0, 5.1等版本的设备支持. 路径:~/Library/Developer/Xcode/iOS D ...
- Storyboards Tutorial 01
Storyboarding 是在ios 5时候引进入的一个非常出色的特性.节省了为app创建user interfaces的时间.
- 【java】StringBuilder的三种清除方法对比
参考链接:https://blog.csdn.net/roserose0002/article/details/6972391
- eclipse中修改JDK版本
eclipse中,一个java项目依赖的JDK,需要进行绑定,但绑定的地方会有多个,类似层级结构. 1. eclipse的window -> preferences -> java com ...
- 常用jar包之commons-digester使用
常用jar包之commons-digester使用 学习了:https://blog.csdn.net/terryzero/article/details/4332257 注意了, digester. ...
- JQuery中$.get(),$.post(),$.ajax(),$.getJSON()的区别
详细解读Jquery各Ajax函数:$.get(),$.post(),$.ajax(),$.getJSON() 一.$.get(url,[data],[callback]) 说明:url为请求地址,d ...