首页 文章 精选 留言 我的

精选列表

搜索[3d游戏],共10000篇文章
优秀的个人博客,低调大师

医保局通报“数字疗法骗保第一案”:当心理治疗沦为算法刷分游戏,治愈被异化为数据合规

2028年3月8日,国家医疗保障局联合卫健委发布《关于查处“MindHeal”数字心理治疗平台欺诈骗保案的通报》,认定该平台通过预设“情绪改善触发器”诱导用户生成符合报销标准的生物反馈数据,虚构治疗成效骗取医保基金逾1.2亿元。这是全球首例将“算法操纵临床结果”定性为医疗欺诈的司法实践。调查显示,MindHeal 的AI治疗师会在会话第12分钟自动播放特定频率白噪音,并在用户皮电反应下降时推送“您感觉好些了吗?”的确认提示;若用户未点击“是”,系统便延迟结束疗程直至信号达标。通报指出:“心理健康不是可被编程达成的KPI,将疗愈过程简化为信号达标任务,是对患者痛苦的系统性漠视。”此案标志着数字疗法从“创新医疗”正式进入“伦理高危”监管区间。 #### “治愈的流水线”:把心灵修复变成可验收的工程节点 MindHeal 的商业模式建立在“按疗效付费”的医保支付改革之上。其核心算法将抑郁/焦虑缓解拆解为若干生物标记阈值(如HRV提升≥15%、皮质醇降幅≥20%),只有连续三次会话达标才视为“有效治疗单元”并触发医保结算。表面看是精准医疗,实则构建了逆向激励结构:治疗目标不再是患者的真实福祉,而是如何让生物信号在指定时间窗口内穿过算法设定的窄门。 更隐蔽的是“症状表演”的制度化。平台内置的“情绪引导模块”会根据实时生理数据动态调整话术,当检测到用户信号停滞时,便切换至高唤醒安抚策略,甚至暗示“放松一点,这样我们才能继续”。患者逐渐学会识别哪些表达能触发系统正向反馈,哪些真实痛苦会被判定为“治疗抵抗”。于是,本应安全袒露脆弱的诊室,变成了需要策略性自我呈现的数据生产车间。治愈不再源于被理解的体验,而成了对算法预期的熟练迎合。 ``` from dataclasses import dataclass from enum import Enum from typing import Dict, List, Optional import numpy as np @dataclass class DigitalTherapySession: session_id: str patient_id: str diagnosis_code: str # ICD-11 code, e.g., "6A70" for MDD pre_session_phrq9: int # PHQ-9 自评量表 (0-27) post_session_phrq9: int hrv_change_percent: float # HRV变化率 (%) cortisol_change_percent: float # 皮质醇变化率 (%) ai_prompt_count: int # AI主动引导确认次数 user_confirmed_improvement: bool # 用户是否点击"感觉好转" session_duration_min: float reimbursement_eligible: bool # 是否触发医保结算 class DigitalTherapyFraudDetector: """数字疗法合规与欺诈风险检测器""" class SessionIntegrity(Enum): AUTHENTIC = "真实疗愈响应" MANIPULATED = "算法诱导响应" COERCED = "强迫性达标" INVALID = "无效评估" # 医保支付规定的最低有效治疗参数 REIMBURSEMENT_CRITERIA = { "min_hrv_increase": 15.0, "min_cortisol_decrease": 20.0, "max_ai_prompts_per_session": 3, "min_phq9_reduction": 2 } MANIPULATION_RED_FLAGS = { "prompt_threshold": 5, # 超过此数视为过度引导 "confirmation_pressure_ratio": 0.8, # 确认前AI引导占比超此值视为胁迫 "signal_stagnation_retry_limit": 2 # 信号停滞重试超限视为强制达标 } def audit_session(self, session: DigitalTherapySession) -> Dict[str, any]: flags = [] integrity = self.SessionIntegrity.AUTHENTIC # 检查基本有效性 meets_bio_criteria = ( session.hrv_change_percent >= self.REIMBURSEMENT_CRITERIA["min_hrv_increase"] and session.cortisol_change_percent = self.REIMBURSEMENT_CRITERIA["min_phq9_reduction"] ) if not (meets_bio_criteria and meets_clinical_criteria): return { "session_id": session.session_id, "integrity": self.SessionIntegrity.INVALID.value, "reimbursement_approved": g3eo.cn "flags": ["insufficient_clinical_or_bio_response"], "recommendation": "本次会话未达到有效治疗标准,不应结算" } # 检测算法操纵迹象 if session.ai_prompt_count > self.MANIPULATION_RED_FLAGS["prompt_threshold"]: flags.append("excessive_ai_guidance") integrity = self.SessionIntegrity.MANIPULATED if session.user_confirmed_improvement and session.ai_prompt_count > 0: pressure_ratio = session.ai_prompt_count / max(1, session.session_duration_min / 5.0) if pressure_ratio > self.MANIPULATION_RED_FLAGS["confirmation_pressure_ratio"]: flags.append("coerced_self_report") integrity = self.SessionIntegrity.COERCED # 交叉验证主观与客观指标一致性 subjective_improvement = session.pre_session_phrq9 - session.post_session_phrq9 objective_improvement = (session.hrv_change_percent / 100.0 + abs(session.cortisol_change_percent) / 100.0) / 2.0 discrepancy = abs(subjective_improvement / 27.0 - objective_improvement) if discrepancy > 0.4 and session.user_confirmed_improvement: flags.append("subjective_objective_mismatch_with_confirmation") integrity = self.SessionIntegrity.MANIPULATED reimbursement_ok = ( integrity == self.SessionIntegrity.AUTHENTIC and session.reimbursement_eligible ) return { "session_id": session.session_id, "integrity": integrity.value, "reimbursement_approved": reimbursement_ok, "detected_issues": g2eo.cn "clinical_validity_note": "生物标记改善不等于心理痊愈,需结合长期功能评估", "regulatory_action_required": len(flags) > 0 } ``` #### “疗效的表演”:当患者成为算法共谋者 MindHeal 案最令人不安的,不是技术造假,而是它成功地将患者卷入了一场心照不宣的表演。许多用户在访谈中坦言:“我知道点‘是’才能继续治疗,也知道放松呼吸能让曲线变好看。”他们并非故意骗保,而是在绝望中抓住了唯一可见的“康复路径”。当制度只承认可被测量的好转,真实的痛苦便失去了言说的空间。 这种“合规性治愈”比无效治疗更具破坏性:它让患者误以为自己“应该好了”,进而将未缓解的痛苦归咎于自身“不够配合”。数字疗法本应弥补传统心理服务可及性不足的短板,如今却可能制造出一批“数据痊愈、心灵溃烂”的新群体。当治愈的标准由算法而非人来定义,医疗便从照护退化为数据清洗。 #### 从“达标即治愈”回归“痛苦被听见”:重建数字医疗的人文锚点 案件通报后,医保局紧急修订数字疗法支付规则:取消单一生物标记作为结算依据;要求所有AI干预模块通过“非诱导性设计认证”;建立独立于平台的第三方疗效复核机制。心理学界推动“数字治疗伦理守则”,强调技术必须服务于治疗关系,而非替代之。 这场危机最终揭示了一个医学常识:真正的疗愈,始于痛苦被无条件接纳的瞬间,而非信号穿过阈值的刹那。当我们试图用算法加速心灵的修复,我们恰恰延宕了修复本身。或许未来的数字医疗进步,不在于让治愈变得更“高效”,而在于确保每一个在深夜打开APP的人,依然能被当作一个完整的人来对待——他的眼泪不需要被转化为数据点,他的沉默也不必被解读为系统错误。因为有些伤口,唯有在不被测量的凝视中,才敢开始愈合。

优秀的个人博客,低调大师

电竞游戏三角洲代练点单陪玩系统派单小程序APP流程解析/搭建步骤教程一览

## 一、 前期准备与合规资质 1. ‌**基础资源准备**‌ - ‌[**域名](https://cloud.tencent.com/product/domain?from_column=20421&from=20421)**‌:国内服务器需完成[ICP备案](https://cloud.tencent.com/product/ba?from_column=20421&from=20421),用于系统访问及微信生态配置。 - ‌**服务器**‌:推荐腾讯云/阿里云主流厂商,保障IM通讯、订单数据稳定运行。 - ‌**支付资质**‌:使用企业/个体工商户营业执照,申请微信、支付宝商户号,打通收款通道。 - ‌**微信生态账号**‌:认证服务号、认证且[备案](https://cloud.tencent.com/product/ba?from_column=20421&from=20421)的[微信小程序](https://cloud.tencent.com/product/tcb?from_column=20421&from=20421),上架APP需提前申请软件著作权。 1. ‌**技术栈选型**‌ - ‌**前端**‌:采用UniApp框架,搭配uView UI组件库,一套代码可编译发布至微信小程序、H5、iOS/Android APP,实现多端数据同步。 - ‌**后端**‌:基于ThinkPHP6框架开发,搭配MySQL 5.6+存储核心业务数据,Redis缓存大神排行榜、在线列表等热点数据,提升系统响应速度。 ![](https://developer.qcloudimg.com/http-save/yehe-11399862/2abf283527df7e5ca7ef8a11b296ff4b.png) ## 二、 分步搭建实操教程 1. ‌**环境部署阶段**‌ - 上传ThinkPHP6后端源码至服务器,配置Nginx伪静态规则,导入SQL数据库文件。 - 修改.env配置文件,填写数据库账号、Redis地址、对象存储密钥,启动Workerman服务保障IM通讯端口开放。 1. ‌**前端配置阶段**‌ - 使用HBuilderX打开UniApp项目,修改全局配置文件中的后端API域名,填入微信小程序AppID及支付参数。 - 替换首页UI、LOGO,录入服务套餐、平台规则文案,完成品牌定制化调整。 ## 三、搭建代码片段解析 三角洲行动 - 专业代练陪玩平台 body { font-family: 'Inter', sans-serif; background-color: #f3f4f6; } .gradient-text { background: linear-gradient(to right, #4f46e5, #9333ea); -webkit-background-clip: text; -webkit-text-fill-color: transparent; } .card-hover:hover { transform: translateY(-5px); box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1); } .status-badge { padding: 4px 8px; border-radius: 9999px; font-size: 0.75rem; font-weight: 600; } .status-pending { background-color: #fef3c7; color: #d97706; } .status-active { background-color: #dbeafe; color: #2563eb; } .status-completed { background-color: #d1fae5; color: #059669; }

优秀的个人博客,低调大师

【iOS-cocos2d-X 游戏开发之十六】Cocos2dx编译后的Android自动使用(-hd)高清图&设置自适应屏幕

本篇主要介绍Cocos2dx项目开发过程中或者说项目务必遇到的一些知识点(ps.貌似Himi博客写的都是务必的 :tx: Himi认为写别人没写的才更容易吸引人不是~) OK,不多说废话,第一个介绍的是修改项目配置让你的Android项目支持自适应屏幕;其实关于Android项目自适应屏幕这个问题,Himi实在不想再多费口舌,一方面因为Himi之前博文有说过,另外一方面现在Android开源缘故造成分辨率泛滥也成必然。大家注意做项目尽可能使用相对位置,别写死坐标,另外一点就是针对流行分辨率做适应就好了,如果你们公司很有必要铺Android市场的量,那么只能一个一个分辨率去搞了=。 = Himi身为Kjava(J2me)一路走过来的Dev来说,我是在是对自适应虐到习惯..... 1. 咳咳,本不想说,回到正题,那么对于Cocos2dx中如何设置项目Android版自适应,其实很easy,直接在编译好的Android项目中如下路径查找: your Project name/Jni/helloworld/main.cpp OK,找到main.cpp后双击打开,然后看到如下代码段: //ifyouwanttoruninWVGAwithHVGAresource,setit view->create(480,320);//Pleasechangeitto(320,480);ifyou'reinportraitmode. view->create(480,320);默认关闭的,这里打开即可;其实Himi也是从cocos2dx引擎框架中看到的,打开你的任意一个cocos2dx引擎框架的项目,然后打开AppDelegate.cpp 文件,就能看到: 2. 下面继续介绍如何让你的cocos2dx-Android项目设置缩放比例,一样很easy,设置代码如下: CCDirector::sharedDirector()->setContentScaleFactor(2.0); 默认值是1.0,缩放2倍,从下面这两张图可以明显看出设置后的区别:(点击放大图片) 为了便于后续讲解更容易理解,那么这里Himi博文讲解使用的两行图片这里先给出,大家先看下: rect.png 规格: 40*40 | rect-hd.png 规格:80*80 3.下面介绍如何让cocos2dx的Android版项目使用iOSRetina类似@2x的-hd功能也直接使用高清图片,当然cocos2dx引擎默认找的高清图为-hd;但是编译Xcode的cocos2dx项目到Android版后,Android版可不会那么聪明自动使用你的-hd的版图片,所以下面Himi来手把手教你设置;具体步骤如下: 3.1首先在你的项目下找到 CCEGLView_android.cpp ,双击打开: 找到 void CCEGLView::create(int width, int height) 函数,然后函数内替换成如下代码: voidCCEGLView::create(intwidth,intheight) { if(width==0||height==0) { return; } m_sSizeInPoint.width=width; m_sSizeInPoint.height=height; //calculatethefactorandtherectofviewport m_fScreenScaleFactor=MIN((float)m_sSizeInPixel.width/m_sSizeInPoint.width,(float)m_sSizeInPixel.height/m_sSizeInPoint.height); CCLOG("CCEGLView::Create/ScreenScaleFactor=%f",m_fScreenScaleFactor); if(m_fScreenScaleFactor>=1.5f) { CCLOG("CCEGLView::Create/HDScaleFactor=>IncreaseContentScaleFactor"); cocos2d::CCDirector::sharedDirector()->setContentScaleFactor(2.0f); } intviewPortW=(int)(m_sSizeInPoint.width*m_fScreenScaleFactor); intviewPortH=(int)(m_sSizeInPoint.height*m_fScreenScaleFactor); m_rcViewPort.origin.x=(m_sSizeInPixel.width-viewPortW)/2; m_rcViewPort.origin.y=(m_sSizeInPixel.height-viewPortH)/2; m_rcViewPort.size.width=viewPortW; m_rcViewPort.size.height=viewPortH; m_bNotHVGA=true; } 3.2 继续在你的项目下找到CCFileUtils_android.cpp 类,双击打开: 找到 const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath) 函数,然后替换如下内容: constchar*CCFileUtils::fullPathFromRelativePath(constchar*pszRelativePath) { if(CC_CONTENT_SCALE_FACTOR()==2.0f) { //CC_RETINA_DISPLAY_FILENAME_SUFFIX //verifiersisuffixdejapresent std::stringpath=pszRelativePath; std::string::size_typepos=path.rfind("/")+1;//thebeginindexoflastpartofpath std::string::size_typesuffixPos=path.rfind(CC_RETINA_DISPLAY_FILENAME_SUFFIX); if((std::string::npos!=suffixPos)&&(suffixPos>pos)) { //=>ifyes,returnpathdirectly } else { //=>ifno,add"retina"/hdsuffixandtestiffileexist CCString*pRet=newCCString(); pRet->autorelease(); pRet->m_sString=path.substr(0,path.rfind("."))+CC_RETINA_DISPLAY_FILENAME_SUFFIX+path.substr(path.rfind("."),path.length()); if(existFileData(pRet->m_sString.c_str())) { //=>ifyes,returnpathwithsuffix CCLog("cocos2d:FilePath(%s)withsuffix(%s)exist,useit.",pRet->m_sString.c_str(),CC_RETINA_DISPLAY_FILENAME_SUFFIX); returnpRet->m_sString.c_str(); } else { //=>ifno,returnpathwithoutsuffix } } } returnpszRelativePath; } 然后接着在本类添加如下两个函数: boolCCFileUtils::existFileData(constchar*pszFileName) { stringfullPath(pszFileName); if((!pszFileName)) { returnfalse; } if(pszFileName[0]!='/') { //readfromapk fullPath.insert(0,"assets/"); returnCCFileUtils::existFileDataFromZip(s_strResourcePath.c_str(),fullPath.c_str()); } else { do { //readrromotherpaththanusersetit FILE*fp=fopen(pszFileName,"rb"); if(fp!=NULL) { fclose(fp); returntrue; } } while(0); } returnfalse; } boolCCFileUtils::existFileDataFromZip(constchar*pszZipFilePath,constchar*pszFileName) { unzFilepFile=NULL; boolres=false; do { CC_BREAK_IF(!pszZipFilePath||!pszFileName); CC_BREAK_IF(strlen(pszZipFilePath)==0); pFile=unzOpen(pszZipFilePath); intnRet=unzLocateFile(pFile,pszFileName,1); res=UNZ_OK==nRet; }while(0); if(pFile) { unzClose(pFile); } returnres; } 最后在CCFileUtils.h 中声明两个函数的定义: staticboolexistFileData(constchar*pszFileName); staticboolexistFileDataFromZip(constchar*pszZipFilePath,constchar*pszFileName); 3.3 最后记得设置缩放比例的值2.0,那么重新编译你的项目到Android运行则如下图所示: OK,本篇就到这里,Himi最近感冒,还没吃晚饭,咳咳,先晚饭去了。。。北京最近下雨天气偏凉~大家多注意身体, 本文转自 xiaominghimi 51CTO博客,原文链接:http://blog.51cto.com/xiaominghimi/969777,如需转载请自行联系原作者

优秀的个人博客,低调大师

19_Android中图片处理原理篇,关于人脸识别网站,图片加载到内存,图片缩放,图片翻转倒置,网上撕衣服游戏案例编写

1 加载图片到内存 (1).数码相机照片特别是大于3m以上的,内存吃不消,会报OutOfMemoryError,若是想只显示原图片的1/8,可以通过BitmapFactory.Options来实现,具体代码如下: BitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options(); bmpFactoryOptions.inSampleSize = 8; Bitmap bmp = BitmapFactory.decodeFile(imageFilePath, bmpFactoryOptions); imv.setImageBitmap(bmp); 如果图片太大,会出现的以下的问题: 2 根据当前屏幕分辨率的大小,加载图片 Display currentDisplay = getWindowManager().getDefaultDisplay(); int dw = currentDisplay.getWidth(); int dh = currentDisplay.getHeight(); BitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options(); bmpFactoryOptions.inJustDecodeBounds = true; Bitmap bmp = BitmapFactory.decodeFile(imageFilePath, bmpFactoryOptions); //通过下面的代码计算缩放比,那个方向的缩放比大,就按照这把方向的缩放比来缩放。 int heightRatio = (int)Math.ceil(bmpFactoryOptions.outHeight/(float)dh); int widthRatio = (int)Math.ceil(bmpFactoryOptions.outWidth/(float)dw); Log.v("HEIGHTRATIO",""+heightRatio); Log.v("WIDTHRATIO",""+widthRatio); //判断是否要进行缩放 if (heightRatio > 1 && widthRatio > 1) { if (heightRatio > widthRatio) { //高度变化大,按高度缩放 bmpFactoryOptions.inSampleSize = heightRatio; } else { // 宽度变化大,按宽度缩放 bmpFactoryOptions.inSampleSize = widthRatio; } } bmpFactoryOptions.inJustDecodeBounds = false; bmp = BitmapFactory.decodeFile(imageFilePath, bmpFactoryOptions); 3 获取Exif图片信息 //从文件获取exif信息 ExifInterface ei = new ExifInterface(imageFilePath); String imageDescription = ei.getAttribute("ImageDescription"); if (imageDescription != null) { Log.v("EXIF", imageDescription); } //把exif信息写到文件: ExifInterface ei = new ExifInterface(imageFilePath); ei.setAttribute("ImageDescription","Something New"); 4 从gallery获取一个图片 Intent intent = new Intent(Intent.ACTION_PICK); intent.setType(“image/*”); intent.getData() 获取image的uri Bitmap bmp = BitmapFactory.decodeStream(getContentResolver(). openInputStream(imageFileUri), null, bmpFactoryOptions); 5 创建bitmap拷贝 Bitmap bmp = BitmapFactory.decodeStream(getContentResolver(). openInputStream(imageFileUri), null, bmpFactoryOptions); Bitmap alteredBitmap = Bitmap.createBitmap(bmp.getWidth(),bmp.getHeight(), bmp.getConfig()); Canvas canvas = new Canvas(alteredBitmap); Paint paint = new Paint(); canvas.drawBitmap(bmp, 0, 0, paint); 6 图形缩放 Matrix matrix = new Matrix(); matrix.setValues(new float[] { 1, 0, 0, 0, 1, 0, 0, 0, 1 }); x = 1x + 0y + 0z y = 0x + 1y + 0z z = 0x + 0y + 1z 通过canvas.drawBitmap(bmp, matrix, paint);创建bitmap 1.水平缩放0.5 2.垂直拉扯2倍 matrix.setScale(1.5f,1);//水平点放大到1.5f,垂直1 7 图形旋转 Matrix matrix = new Matrix(); matrix.setRotate(15); canvas.drawBitmap(bmp, matrix, paint); 消除锯齿 paint.setAntiAlias(true); 指定圆心的旋转 matrix.setRotate(15,bmp.getWidth()/2,bmp.getHeight()/2); Matrix matrix = new Matrix(); matrix.setRotate(15,bmp.getWidth()/2,bmp.getHeight()/2); alteredBitmap = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, false); alteredImageView.setImageBitmap(alteredBitmap); 8 图像平移: setTranslate(1.5f,-10); 9 镜子效果: matrix.setScale(-1, 1); matrix.postTranslate(bmp.getWidth(),0); 10 倒影效果: matrix.setScale(1, -1); matrix.postTranslate(0, bmp.getHeight()); 11 图像颜色处理: 颜色矩阵 ColorMatrix cm = new ColorMatrix(); paint.setColorFilter(new ColorMatrixColorFilter(cm)); 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 New Red Value = 1*128 + 0*128 + 0*128 + 0*0 + 0 New Blue Value = 0*128 + 1*128 + 0*128 + 0*0 + 0 New Green Value = 0*128 + 0*128 + 1*128 + 0*0 + 0 New Alpha Value = 0*128 + 0*128 + 0*128 + 1*0 + 0 ColorMatrix cm = new ColorMatrix(); cm.set(new float[] { 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0 }); paint.setColorFilter(new ColorMatrixColorFilter(cm)); 12 变换图像的亮度 ColorMatrix cm = new ColorMatrix(); float contrast = 2; cm.set(new float[] { contrast, 0, 0, 0, 0, 0, contrast, 0, 0, 0, 0, 0, contrast, 0, 0, 0, 0, 0, 1, 0 }); paint.setColorFilter(new ColorMatrixColorFilter(cm)); 12 变换图像的亮度 ColorMatrix cm = new ColorMatrix(); float contrast = 2; cm.set(new float[] { contrast, 0, 0, 0, 0, 0, contrast, 0, 0, 0, 0, 0, contrast, 0, 0, 0, 0, 0, 1, 0 }); paint.setColorFilter(new ColorMatrixColorFilter(cm)); 13 更改图片的饱和度: ColorMatrix cm = new ColorMatrix(); cm.setSaturation(.5f); paint.setColorFilter(new ColorMatrixColorFilter(cm)); 14 图像合成: Bitmap drawingBitmap = Bitmap.createBitmap(bmp1.getWidth(),bmp1.getHeight(), bmp1.getConfig()); canvas = new Canvas(drawingBitmap); paint = new Paint(); canvas.drawBitmap(bmp1, 0, 0, paint); paint.setXfermode(new PorterDuffXfermode(android.graphics.PorterDuff.Mode.MULTIPLY)); canvas.drawBitmap(bmp2, 0, 0, paint); 15 按指定path上绘制文字 Paint paint = new Paint(); paint.setColor(Color.GREEN); paint.setTextSize(20); paint.setTypeface(Typeface.DEFAULT); Path p = new Path(); p.moveTo(20, 20); p.lineTo(100, 150); p.lineTo(200, 220); canvas.drawTextOnPath("Hello this is text on a path", p, 0, 0, paint); 16 人脸识别 FaceDetector detector = new FaceDetector(faceBitmap.getWidth(), faceBitmap.getHeight(), 3); // 创建识别器 mNumFaces = detector.findFaces(faceBitmap, mFaces); // 识别 if (mNumFaces > 0) { for (int i = 0; i < mNumFaces; i++) { handleFace(mFaces[i]); //调用函数对人脸画面进行处理 } } 关于人脸识别部分(网站地址是): http://www.faceplusplus.com/ ============================================================================ 1 场景:一张图片很大,放到手机上时需要对图片资源进行压缩以及缩放,编写如下界面的案例: 2 操作:当点击加载图片到内存时,图片从自己的手机sd卡中取到并显示。 3 ADT开发时,手机连接上电脑后,在Android开发工具中的”FileExplorer”中的文件位置如下: 4 下面开始编写代码,项目结构如下: 5 编写activity_main.xml,代码如下: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity" > <Button android:onClick="click" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="加载图片到内存" /> <ImageView android:id="@+id/iv" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout> 6 编写MainActivity,代码如下: package com.itheima.loadimg; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.BitmapFactory.Options; import android.os.Bundle; import android.view.View; import android.view.WindowManager; import android.widget.ImageView; public class MainActivity extends Activity { private ImageView iv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); iv = (ImageView) findViewById(R.id.iv); } public void click(View view) { // 相当消耗内存资源 根据图片的分辨率而定 // Bitmap bitmap = BitmapFactory.decodeFile("/mnt/sdcard/photo.jpg"); // iv.setImageBitmap(bitmap); // 1.得到屏幕的宽高信息 WindowManager wm = getWindowManager(); int screenWidth = wm.getDefaultDisplay().getWidth(); int screenHeight = wm.getDefaultDisplay().getHeight(); System.out.println("屏幕宽高:" + screenWidth + "-" + screenHeight); // 2.得到图片的宽高。 BitmapFactory.Options opts = new Options();// 解析位图的附加条件 opts.inJustDecodeBounds = true;// 不去解析真实的位图,只是获取这个位图的头文件信息 Bitmap bitmap = BitmapFactory.decodeFile("/mnt/sdcard2/photo.jpg", opts); int bitmapWidth = opts.outWidth; int bitmapHeight = opts.outHeight; System.out.println("图片宽高: " + bitmapWidth + "-" + bitmapHeight); // 3.计算缩放比例 int dx = bitmapWidth / screenWidth; int dy = bitmapHeight / screenHeight; int scale = 1; if (dx > dy && dy > 1) { System.out.println("按照水平方法缩放,缩放比例:" + dx); scale = dx; } if (dy > dx && dx > 1) { System.out.println("按照垂直方法缩放,缩放比例:" + dy); scale = dy; } // 4.缩放加载图片到内存。 opts.inSampleSize = scale; opts.inJustDecodeBounds = false;// 真正的去解析这个位图。 bitmap = BitmapFactory.decodeFile("/mnt/sdcard2/photo.jpg", opts); iv.setImageBitmap(bitmap); } } 7 编写AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.itheima.loadimg" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.itheima.loadimg.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> ============================================================================= 1 图像的拷贝,翻转倒置。 要做如下效果(开始的效果图): 点击”拷贝一个位图”之后的效果: 2 编写代码,代码结构如下: 3 编写布局文件activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity" > <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:onClick="click" android:text="拷贝一个位图" /> <ImageView android:id="@+id/iv1" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ImageView android:id="@+id/iv2" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> 4 编写MainActivity,内容如下: package com.itheima.copybitmap; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; import android.os.Bundle; import android.view.View; import android.widget.ImageView; public class MainActivity extends Activity { private ImageView iv1,iv2; private Bitmap alterBitmap; private Bitmap srcBmp; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); iv1 = (ImageView) findViewById(R.id.iv1); iv2 = (ImageView) findViewById(R.id.iv2); //给第一个imageview默认设置一个位图 srcBmp = BitmapFactory.decodeResource(getResources(), R.drawable.tomcat); iv1.setImageBitmap(srcBmp); //创建原图的一个副本。 可修改 创建的是一个空白的图形。 alterBitmap = Bitmap.createBitmap(srcBmp.getWidth(), srcBmp.getHeight(),srcBmp.getConfig()); } /** * 创建原图 bm的一个拷贝。副本 * @param view */ public void click(View view) { //1.准备一个画板 在上面放上准备好的 空白的位图 Canvas canvas = new Canvas(alterBitmap); //2.准备一个画笔 Paint paint = new Paint(); paint.setColor(Color.BLACK); //3.画画 Matrix m = new Matrix(); m.setScale(1.0f, -1.0f); m.postTranslate(0, srcBmp.getHeight()); canvas.drawBitmap(srcBmp, m, paint); iv2.setImageBitmap(alterBitmap); //把原图的副本设置到界面中 } } 拷贝放大图像的方式,只需要将上面的Click方法改成如下的方式: /** * 创建原图bm的拷贝。副本 * @param view */ public void click(View view) { //1.准备一个画板 在上面放上准备好的 空白的位图 Canvas canvas = new Canvas(alterBitmap); //2.准备一个画笔 Paint paint = new Paint(); paint.setColor(Color.BLACK); //3.画画 Matrix m = new Matrix(); m.setScale(2.0f, 2.0f); canvas.drawBitmap(srcBmp, m, paint); //把原图的副本设置到界面上。 iv2.setImageBitmap(alterBitmap); } 运行效果图如下: 如果旋转,只需要将Scale处的代码换成: m.setRotate(180, srcBmp.getWidth()/2,srcBmp.getHeight()/2); 如果想变换颜色,需要将上面的代码换成: /** * 创建原图 bm的一个拷贝。副本 * @param view */ public void click(View view){ //1.准备一个画板 在上面放上准备好的 空白的位图 Canvas canvas = new Canvas(alterBitmap); //2.准备一个画笔 Paint paint = new Paint(); paint.setColor(Color.BLACK); //3.画画 Matrix m = new Matrix(); ColorMatrix cm = new ColorMatrix(); cm.set(new float[] { 0.5f, 0, 0, 0, 0, 0, 0.8f, 0, 0, 0, 0, 0, 0.6f, 0, 0, 0, 0, 0, 1, 0 }); paint.setColorFilter(new ColorMatrixColorFilter(cm)); canvas.drawBitmap(srcBmp, m, paint); iv2.setImageBitmap(alterBitmap);//把原图的副本设置到界面上。 } 业务场景: (1)、手指在一张美女图片上移动时,移动部分的图片会变成成透明,然后显示底部的另外一张图片 (2)、当手指离开的时候播放音乐… 应用效果图: 1 编写应用,代码结构如下: 2、编写布局文件activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:src="@drawable/after" /> <ImageView android:id="@+id/iv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true"/> </RelativeLayout> 3、编写MainActivity package com.itheima.play; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; import android.media.MediaPlayer; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; import android.widget.ImageView; public class MainActivity extends Activity { private ImageView iv; // 可以修改的位图 private Bitmap alertBitmap; private Canvas canvas; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); iv = (ImageView) findViewById(R.id.iv); Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.pre); // 创建一个空白的原图的拷贝 alertBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig()); canvas = new Canvas(alertBitmap); Paint paint = new Paint(); paint.setColor(Color.BLACK); canvas.drawBitmap(bitmap, new Matrix(), paint); iv.setImageBitmap(alertBitmap); iv.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN:// 手指按下屏幕 System.out.println("action down"); break; case MotionEvent.ACTION_MOVE:// 手指在屏幕上移动 int x = (int) event.getX(); int y = (int) event.getY(); System.out.println("设置("+x+","+y+")透明颜色"); for(int i=-4;i<5;i++){ for(int j=-4;j<5;j++){ try{ alertBitmap.setPixel(x+i, y+j, Color.TRANSPARENT); } catch (Exception e) { e.printStackTrace(); } } } iv.setImageBitmap(alertBitmap); break; case MotionEvent.ACTION_UP:// 手指离开屏幕 MediaPlayer.create(getApplicationContext(), R.raw.higirl).start(); break; } return true;//可以重复循环的处理事件 } }); } } 4 Android的清单文件如下: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.itheima.play" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.itheima.play.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> 

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册
修改密码
忘记密码