elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Estamos en la red social de Mastodon


  Mostrar Mensajes
Páginas: [1]
1  Programación / Programación C/C++ / OpenCv en: 17 Julio 2012, 19:57 pm
 :huh: Hola a todos, soy nuevo en este foro, espero yo poder ayudarles, pero en este momento soy yo el que necesita su ayuda...
Resulta que estoy programando en Microsoft Visual C++ 2010 con OpenCv 2.1. En el principio todo iva bien hasta que cvCapture comenzo a lanzar errores, lo que sucedio fue lo siguiente:

Código
  1. //Libreria Creadora
  2. #include "stdafx.h"
  3. //Libreria donde encontramos funciones para el Mouse
  4. #include <windows.h>
  5. //Libreria de OpenCV
  6. #include <cv.h>
  7. //Sub Lbreria de OpenCV
  8. #include <highgui.h>
  9. #include <cxcore.h>
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12.  
  13. #define A (DWORD)50
  14. #define B (DWORD)50
  15.  
  16.  
  17. int main( int argc, char** argv[] )
  18. {
  19. int i,j,centroi,centroj,a,b,c,dif1,dif2,h,w,X,Y;
  20. int di=0;
  21. int dj=0;
  22. double max=0;
  23. int cont=0;
  24. int cond=0;
  25. float me=1/2;
  26. int letra;
  27. char foto;
  28. //Abrimos La Cámara
  29. CvCapture* camara=0;
  30. camara=cvCaptureFromCAM(1);
  31. //Definimos las variables que toman las Capturas
  32. IplImage* imagen;
  33. IplImage* imagen2;
  34. IplImage* imagen3;
  35.  
  36. //Programa Principal
  37. while(true)
  38. {
  39. printf("Para Abrir Visor de Imagen presione '1' \n");
  40. printf("Para Abrir MousePad presione '2' \n");
  41. printf("Para Salir del Programa presione '3' \n");
  42. printf("Número: ");
  43. scanf("%d",&letra);
  44. if (letra==2)
  45. {
  46. while(true)
  47. {
  48. int cont2=0;
  49. int di=0;
  50. int dj=0;
  51. imagen2 = cvQueryFrame(camara);
  52. cvSaveImage("saliendo.jpg",imagen2);
  53. imagen=cvLoadImage("saliendo.jpg",0);
  54. h=imagen->width;
  55. w=imagen->height;
  56. int sumai=0;
  57. int sumaj=0;
  58. if(!imagen)
  59. {
  60. break;
  61. }
  62. for (i=0;i=h;i++)
  63. {
  64. for (j=0;j=w;j++)
  65. {
  66. int pixel=0;
  67. pixel = ((uchar *)(imagen->imageData + i*imagen->widthStep))[j*imagen->nChannels +0];
  68. if (pixel>250)
  69. {
  70. sumai = sumai+i;
  71. sumaj = sumaj+j;
  72. max= (pixel>max) ? pixel:max;
  73. }
  74. }
  75. }
  76. centroi = sumai/cont;
  77. centroj = sumaj/cont;
  78. a=centroi;
  79. b=centroj;
  80. c=cont;
  81. if (max=255)
  82. {
  83. while(true)
  84. {
  85. imagen3 = cvQueryFrame(camara);
  86. cvSaveImage("saliendo.jpg",imagen3);
  87. imagen=cvLoadImage("saliendo.jpg",1);
  88. if(!imagen) {break;}
  89. for (i=0;i=h;i++)
  90. {
  91. for (j=0;j=w;j++)
  92. {
  93. int pixel = ((uchar *)(imagen->imageData + i*imagen->widthStep))[j*imagen->nChannels +0];
  94. if (pixel>250)
  95. {
  96. sumai = sumai+i;
  97. sumaj = sumaj+j;
  98. cont = cont+1;
  99. }
  100. }
  101. }
  102. centroi = sumai/cont;
  103. centroj = sumaj/cont;
  104. if ((cont-c)<20 && ((cont-c)>-20))
  105. {
  106. dif1=0;
  107.    dif2=0;
  108. }
  109. else
  110. {
  111. dif1=centroi-a;
  112. dif2=b-centroj;
  113. }
  114. di=di + dif1;
  115. dj=dj + dif2;
  116. a=centroi;
  117. b=centroj;
  118. cont2=cont2+1;
  119. if (cont2==3)
  120. {
  121. if ((di<8) & (dj<8))
  122. {
  123. mouse_event(MOUSEEVENTF_LEFTDOWN, A, B, 0, 0);
  124. mouse_event(MOUSEEVENTF_LEFTUP, A, B, 0, 0);
  125. break;
  126. }
  127. if ((di>8) || (dj>8))
  128. {
  129. INPUT *buffer = new INPUT[3]; //Asignar un buffer
  130. X=di*10;
  131. Y=dj*10;
  132. mouse_event(MOUSEEVENTF_ABSOLUTE || MOUSEEVENTF_MOVE, X, Y, 0, 0);
  133. break;
  134. }
  135. }
  136. }
  137. }
  138. }
  139. }
  140. else if (letra==3)
  141. {break;}
  142. else
  143. {
  144. printf("Error Ingrese Numero Nuevamente \n");
  145. printf("Numero: ");
  146. scanf("%d",&letra);
  147. }
  148. }
  149. //Ciclo de la Aplicación
  150.  
  151. cvReleaseCapture(&camara);
  152. return 0;
  153. }
  154.  


Este corresponde a un programa que identifica puntos de una camara y si se mueven el mouse se mueve, de lo contrario si no se mueve es un click..

En esto me salen varios errores:

1>------ Build started: Project: tarea, Configuration: Debug Win32 ------
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(299,5): warning MSB8004: Output Directory does not end with a trailing slash.  This build instance will add the slash as it is required to allow proper evaluation of the Output Directory.
1>  tarea.cpp
1>tarea.cpp(46): warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\stdio.h(304) : see declaration of 'scanf'
1>tarea.cpp(150): warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\stdio.h(304) : see declaration of 'scanf'
1>tarea.cpp(30): warning C4101: 'foto' : unreferenced local variable
1>c:\opencv\include\opencv\cxoperations.hpp(81): warning C4793: '`anonymous namespace'::CV_XADD' : function compiled as native :
1>     Inline native assembly not supported in managed code
1>tarea.obj : warning LNK4248: unresolved typeref token (0100001E) for 'CvCapture'; image may not run
1>  tarea.vcxproj -> C:\Users\Eduardo\documents\visual studio 2010\Projects\tarea\tarea\..\..\..\..\..\Desktop\Tarea\tarea.exe
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(562,5): error MSB6006: "mt.exe" exited with code 31.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Si me pueden ayudar ahora seria ideal, ya que si logro hacer esto no reprobare mi curso..de ante mano gracias...

Y es un gusto conocerlos
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines