Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Ellias Garcia

[webcam] + Asp + Edição de Imagem

Recommended Posts

Olá este é meu primeiro post, gostaria de uma ajuda dos desenvolvedores, fiz uma busca no forum, mas não encontrei nada que fosse resolvido as perguntas anteriores sobre webcam e asp, a unica coisa que gostaria é retirar fotos atraves de uma webcam e colocar no perfil do usuário. Achei este site que faz mais ou menos a função que, desejo colocar o interessante é que está em asp, gostaria de uma ajuda pra começar a desenvolver e algumas dicas.

url: exemplo

http://www.heberalmeida.com/fotos

Compartilhar este post


Link para o post
Compartilhar em outros sites

como esta seu projeto ????

você pode usar este codigo para selecionar o modo

Câmera ou Foto local

 

//
var winsDttInstance = new Object();
var jsWinsDttReady = false;
var swfWinsDttReady = false;
var WaitWinsDtti = 0;
var winsDttActionFile="savewinsdtt.asp";
var TakePhotoID = "btnTakePhoto";
var ResetTakePhotoID = "btnResetTakePhoto";



function isWinsDttReady()
{	
	return jsWinsDttReady;
}
function setWinsDttSwfIsReady()
{
	swfWinsDttReady = true;
}

//类模块开始

function winsDtt(id)
{
	jsWinsDttReady = true; 
	
	this.UpFileName = "";
	this.LastVersion = "";
	this.LastUpGradeURL = "";
	this.haveCamera = false;
	
	if (navigator.appName.indexOf("Microsoft") != -1)
	{
		this.SwfInstance = window[id];
	}
	else
	{
		this.SwfInstance = document[id];
	}
	this.UpFileName = "";
	this.isInPhoto = false;
	this.LastVersion = "";
	this.LastUpGradeURL = "";
	this.CameraMode = 1; //1:摄像头模式; 2:本地文件模式
	this.isUpLoadLocalFile = false;
	this.CheckhaveCamera = function(){return this.SwfInstance.CheckhaveCamera()};
	this.GetLastVersion = function(){this.SwfInstance.GetLastVersion();};
	this.GetUpGradeURL = function(){this.SwfInstance.GetUpGradeURL();};
	this.ResetBg = function(){this.SwfInstance.ResetBg();};
	this.ChangeBg = function(pic){this.SwfInstance.ChangeBg(pic);};
	this.LoadLocalPic = function(pic){this.SwfInstance.LoadLocalPic(pic);};
	this.SetActionFile = function (file){this.SwfInstance.SetActionFile(file);};
	this.ResetPhoto = function()
		{
			if(this.isInPhoto)
			{
				this.isInPhoto = false;
				this.SwfInstance.ResetPhoto();
			}
		};
	this.SavePhoto = function()
		{
			if(this.CameraMode == 1)
			{
				if(this.isInPhoto)
					this.SwfInstance.SavePhoto();
				else
					alert("Por favor, selecione o botão foto.");
			}
			else if(this.CameraMode == 2)
			{
				if(this.isUpLoadLocalFile)
					this.SwfInstance.SavePhoto();
				else
					alert("Favor enviar foto do local.");
			}
		};
	this.TakePhoto = function()
		{
			if(!this.isInPhoto)
			{
				this.isInPhoto = true;
				this.SwfInstance.TakePhoto();
			}
			else
			{
				if(confirm("Clique em Re-e para tirar outra Foto"))
					this.ResetPhoto();
			}
		};
	this.ZoomOut = function(){this.SwfInstance.ZoomOut();};
	this.SetBright = function(num){this.SwfInstance.SetBright(num);}
	this.SetContrast = function(num){this.SwfInstance.SetContrast(num);};
	this.SetSaturation = function(num){this.SwfInstance.SetSaturation(num);};
	this.ResetFilter = function()
		{
			if(confirm("Padrão de brilho, contraste, saturação?"))
			{
				Bar1.setSldPoint(255);
				Bar2.setSldPoint(500);
				Bar3.setSldPoint(150);
				this.SwfInstance.ResetFilter();

			}
		};
	this.ZoomIn  = function(){this.SwfInstance.ZoomIn();};

	this.GetAuthor = function(){return this.SwfInstance.GetAuthor();};
	this.GetSite = function(){return this.SwfInstance.GetSite()}
	this.GetProductName = function(){return this.SwfInstance.GetProductName()}
	this.GetNowVersion = function(){return this.SwfInstance.GetNowVersion()}
	this.GetCameras = function(){return this.SwfInstance.GetCameras();};
	this.About=function()
		{
			var msg = "";
			var msg2 = ""
			msg += "Nome do produto:"+this.GetProductName()+"\n";
			var nowVer = this.GetNowVersion();
			var lastVer = this.LastVersion;
			msg += "Versão:"+nowVer+"\n";
			if(lastVer=="")
				msg += "Versão mais recente número:null.Não é possível acessar, por favor, verifique a sua rede.\n";
			else
				msg += "Versão mais recente número:"+lastVer+"\n";
			if( lastVer!="" && nowVer!=lastVer )	
				msg2 = "Erro: " + this.LastVersion + " ?"
			msg += "Autor:"+this.GetAuthor()+"\n";
			msg += "Website:"+this.GetSite()+"\n";

			alert(msg);
			if(msg2!="")
				if(confirm(msg2))
					location.href=this.LastUpGradeURL;
		}
	this.Upgrade = function()
	{
		var nowVer = this.GetNowVersion();
		var lastVer = this.LastVersion;
		var msg = "";
		msg += "当前版本号:"+nowVer+"\n";
		if(lastVer=="")
		{
			msg += "最新版本号:null.无法获取,请检查网络.\n";
			alert(msg);
		}
		else if(nowVer!=lastVer)
		{
			msg += "最新版本号:"+lastVer+"\n";
			msg += "有升级的版本,是否升级到最新版: " + this.LastVersion + " ?"
			if(confirm(msg))
				location.href=this.LastUpGradeURL;
		}
		else
		{
			msg += "最新版本号:"+lastVer+"\n";
			msg += "已经是最新版本,不需要升级.";
			alert(msg);
		}

	}
	
}



function WinsUpDTTcompleteHandler(filename)
{
	winsDttInstance.UpFileName = filename;
}
function GetWinsDttLastVersioncompleteHandler(ver)
{
	winsDttInstance.LastVersion = ver;
}
function GetWinsDttUpGradeURLcompleteHandler(path)
{
	winsDttInstance.LastUpGradeURL = path;
}
function CheckhaveCameraHandler(v)
{
	winsDttInstance.haveCamera = v;
}




function WinsDttFlashDebug(str)
{
	alert(str);
}


function InitWinsDtt(id)
{
	winsDttInstance=new winsDtt(id);
	winsDttInstance.SetActionFile(winsDttActionFile);
	winsDttInstance.GetLastVersion();
	winsDttInstance.GetUpGradeURL();
	if(swfWinsDttReady)
	{
		SetWinsDttMode();
	}
	else
	{
		setTimeout("WaitWinsDttReady()",50); 
	}
}

function SetWinsDttMode()
{
	if(winsDttInstance.CheckhaveCamera())
		winsDttInstance.CameraMode=1;
	else
		winsDttInstance.CameraMode=2;
	ChangeWinsDttMode(winsDttInstance.CameraMode);
}


function ChangeWinsDttMode(mode)
{
	if(mode==1)
	{
		if(!winsDttInstance.haveCamera)
		{
			alert("Erro");
			ChangeWinsDttMode(2);
			return false;
		}
		else
		{
			winsDttInstance.CameraMode=1;
			document.getElementById("rdidttSource1").checked = true;
			document.getElementById("rdidttSource2").checked = false;
			document.getElementById("trfileup").style.display = "none";
			
			document.getElementById(TakePhotoID).disabled  = false;
			document.getElementById(ResetTakePhotoID).disabled  = false;
			//这里启用Flash摄像头

		}
	}
	else
	{
		winsDttInstance.CameraMode=2;
		document.getElementById("rdidttSource1").checked = false;
		document.getElementById("rdidttSource2").checked = true;
		document.getElementById("trfileup").style.display = "";

		document.getElementById(TakePhotoID).disabled  = true;
		document.getElementById(ResetTakePhotoID).disabled  = true;
			//这里禁用Flash摄像头
	}
}



function WaitWinsDttReady()
{
	if((!swfWinsDttReady) && WaitWinsDtti<200)
	{
		WaitWinsDtti++;
		setTimeout("WaitWinsDttReady()",50); 
	}
	else
	{
		SetWinsDttMode();
	}
}


function LoadWinsDttFile(pic)
{
	winsDttInstance.LoadLocalPic(pic);
	winsDttInstance.isUpLoadLocalFile = true;
	document.frmfileup.reset();
	document.getElementById("upmsgspan").innerHTML="";

}





function BeforeUpLocalDttImg(frm)
{
	if(frm.txtfile.value=="")
	{
		alert("Selecione uma imagem local e, em seguida, fazer upload botão!");
		frm.txtfile.focus();
		return false;
	}
	var fname = frm.txtfile.value.toUpperCase();
	var   sExp   =   fname.substring(fname.lastIndexOf('.'),fname.length);   
	if(!(sExp==".JPG" || sExp==".GIF"))
	{
		alert("Apenas suporta jpg e gif!");
		frm.txtfile.focus();
		return false;
	}
	document.getElementById("upmsgspan").innerHTML="Carregando……";
	frm.action = winsDttActionFile + "?action=upfile";
}

-----
<script type="text/javascript">
	  var flagnum=0;
	  function beforeSubmit(frm)
	  {
		  var msginfoobj = document.getElementById("msginfo");
		if(winsDttInstance.CameraMode == 1)
		{
			  if(!winsDttInstance.CheckhaveCamera())
			{
				alert("Não detectou câmera ou câmera ocupada. Por favor conecte a câmera/webcam e, em seguida, atualize a página e tente novamente.");
				return false;
			}
			if(!winsDttInstance.isInPhoto)
			{
				alert("Por favor, ponto câmera botão.");
				return false;
			}
		}
		else if(winsDttInstance.CameraMode == 2)
		{
			if(!winsDttInstance.isUpLoadLocalFile)
			{
				alert("Favor enviar foto do local.");
				return false;
			}
		}
		if(frm.title.value == "")
		{
			alert("Preencha o título!");
			frm.title.focus();
			return false;
		}
		if(frm.delpass.value == "")
		{
			alert("Preencha a senha administrativa!");
			frm.delpass.focus();
			return false;
		}
		msginfoobj.innerText = "Enviando e criando foto, por favor aguarde...";
		msginfoobj.style.display = "";
		winsDttInstance.SavePhoto();
		setTimeout("GetUpDttFileName()",1000);
		return false;
	  }
	  function GetUpDttFileName()
	  {
		  var msginfoobj = document.getElementById("msginfo");
		var filename = winsDttInstance.UpFileName;
		  if(filename!="")
		{
			msginfoobj.innerText = "Foto enviada com sucesso, a informação é guardada no banco de dados...";
			msginfoobj.style.display = "";
			document.form1.dttfilename.value = filename;
			document.form1.submit();
		}
		if(flagnum>90)
		{
			alert("Erro, por favor, verifique as configurações de rede e servidor, existem dúvidas, entre em contato com o administrador.");
			msginfoobj.style.display = "none";
			return false;
		}
		setTimeout("GetUpDttFileName()",1000);
		  flagnum++;
	  }
	  </script>

que é o que ele usa para selecionar entre camera e foto local, depois é só aplicar as molduras, você depois pode manipular as imagens usando o ASPJpeg tb

Compartilhar este post


Link para o post
Compartilhar em outros sites

Ambos os sites citados utilizaram Flash para interagir com a Webcam e provavelmente uma linguagem Server-Side + Js para salvar no servidor.

 

Vou mover o tópico para a área de Flash, pois provavelmente lá saberão lhe ajudar com essa interação entre Flash + Webcam. Depois você posta em ASP novamente quando for editar a imagem.

 

 

Obs. o JS postado pelo Xan é utilizado nos dois sites tbm.

 

 

Tópico movido:

 

Origem: ASP http://forum.imasters.com.br/public/style_emoticons/default/seta.gif Destino: Flash & ActionScript

Compartilhar este post


Link para o post
Compartilhar em outros sites

Já tem o SWF? Sabe o que ele retorna e onde retorna?

 

A principio parece que o retorno é no Js, mas não ficou claro como o SWF salva a imagem.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.