我创建了一个比赛游戏,摄像机跟随汽车,代码如下.除了场景中有一个精灵(100px,100px)作为按钮.问题是:当摄像机移动时,按钮永远不动.按钮必须总是在屏幕上显示.但它不动.我该怎么办?
mCamera.setChaseEntity(sprite);
Run Code Online (Sandbox Code Playgroud) 我在拍摄照片时尝试添加叠加效果.我可以在预览中成功添加叠加,但是一旦我点击照片捕捉按钮,叠加视图(大约40像素)将颠倒,我也尝试将图像保存在相册中,但保存的图像不包含叠加图像.
我附上以下,如果我错了请指导我?
//In ViewDidLoad//
OverlayView *overlay = [[OverlayView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
[picker setDelegate:self];
picker.showsCameraControls = YES;
picker.navigationBarHidden = YES;
picker.toolbarHidden = YES;
picker.wantsFullScreenLayout = YES;
picker.cameraViewTransform = CGAffineTransformScale(picker.cameraViewTransform, 1, 1.24299);
picker.cameraOverlayView = overlay;
[self presentModalViewController:picker animated:YES];
[picker release];
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Access the uncropped image from info dictionary
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
// Save image
UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
} …Run Code Online (Sandbox Code Playgroud) 我是OPENCV的新手,所以如果我在这里缺少简单的东西,请耐心等待.
我正在尝试制定一个基于摄像头的系统,该系统可以通过以下假设连续输出车辆的速度:1.摄像机水平放置,车辆经过相机镜头3到5英尺附近.2.速度不会超过30KM /小时
我希望从光学鼠标的概念开始,它检测表面图案中的位移.但是我不清楚当车辆开始进入车架时如何处理背景.
有两种方法我对实验感兴趣,但我正在寻找进一步的输入.
请提出更正和修正建议.此外,我请求更有经验的成员帮助我有效地编写此过程,因为我不知道哪个是最正确的函数在这里使用.
提前致谢.
我尝试使用Aforge编写一个小的代码来捕获一个框架我引用了Aforge.dll和AForge.Video.DirectShow.dll代码如下,但我做错了.警告我得到"名称videoDevices在当前上下文中不存在.我认为它必须在我尝试创建该变量的地方做,但我不确定在哪里放置按钮的代码以使其初始化.错误在visual studio中显示为对象"videoDevices"下的红线
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AForge;
using AForge.Video.DirectShow;
namespace AforgeCam
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
if (videoDevices.Count == 0)
throw new ApplicationException();
foreach (FilterInfo device in videoDevices)
{
VideoCaptureDevice videoSource = new VideoCaptureDevice(device.MonikerString);
videoSource.DesiredFrameSize = new Size(320, 240);
videoSource.DesiredFrameRate = 15;
videoSourcePlayer1.VideoSource = videoSource;
videoSourcePlayer1.Start();
}
} …Run Code Online (Sandbox Code Playgroud) 我正在从iPhone相机保存图像,我管理委托方法:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
Run Code Online (Sandbox Code Playgroud)
在这里我需要知道:
[info objectForKey:UIImagePickerControllerReferenceURL]
Run Code Online (Sandbox Code Playgroud)
但是如果我只拍了一张照片总是零,如果不同于nil加载来自相机胶卷的照片.这是为什么?
我正在尝试在OpenGL中设置一个摄像头来查看三维中的一些点.要做到这一点,我不希望使用旧的,固定功能的风格(glMatrixMode(),glTranslate,等等),而是建立模型视图投影矩阵我自己和我的顶点着色器使用它.正交投影就足够了.
关于这个的很多教程似乎都使用了glm库,但由于我是OpenGL的新手,我想以正确的方式学习它,然后使用一些第三方库.此外,大多数教程没有描述如何使用glMotionFunc()和glMouseFunc()将相机放置在空间中.
所以,我想我正在寻找一些示例代码和指导如何在3D中查看我的分数.这是我写的顶点着色器:
const GLchar *vertex_shader = // Vertex Shader
"#version 330\n"
"layout (location = 0) in vec4 in_position;"
"layout (location = 1) in vec4 in_color;"
"uniform float myPointSize;"
"uniform mat4 myMVP;"
"out vec4 color;"
"void main()"
"{"
" color = in_color;"
" gl_Position = in_position * myMVP;"
" gl_PointSize = myPointSize;"
"}\0";
Run Code Online (Sandbox Code Playgroud)
我将MVP的初始值设置为我的着色器设置方法中的单位矩阵,它给出了我的点的正确2D表示:
// Set up initial values for uniform variables
glUseProgram(shader_program);
location_pointSize = glGetUniformLocation(shader_program, "myPointSize");
glUniform1f(location_pointSize, 25.0f);
location_mvp = glGetUniformLocation(shader_program, "myMVP");
float mvp_array[16] = {1.0f, 0.0f, 0.0f, 0.0f, …Run Code Online (Sandbox Code Playgroud) 所以我一直在使用GLM库在OpenGL和C++中实现的相机出现问题.我所瞄准的相机类型是一个飞行相机,可以轻松探索3D世界.我已经设法使相机工作得非常好,它很好而且流畅,环顾四周,机芯看起来很漂亮和正确.
我似乎唯一的问题是沿着摄像机的X和Y轴(向上和向下看)的旋转引入了绕它的Z轴的一些旋转.这导致世界在旅行时轻微翻滚.
作为一个例子......如果我在相机前面有一个方形四边形并以圆周运动移动相机,那么就像用头看一圈一样,一旦动作完成,四边形将略微滚动如果你歪着头
我的相机目前是一个组件,我可以附加到我的场景中的对象/实体.每个实体都有一个"框架",它基本上是该实体的模型矩阵.Frame包含以下属性:
glm::mat4 m_Matrix;
glm::vec3 m_Position;
glm::vec3 m_Up;
glm::vec3 m_Forward;
Run Code Online (Sandbox Code Playgroud)
然后相机使用它们来创建适当的viewMatrix,如下所示:
const glm::mat4& CameraComponent::GetViewMatrix()
{
//Get the transform of the object
const Frame& transform = GetOwnerGO()->GetTransform();
//Update the viewMatrix
m_ViewMatrix = glm::lookAt(transform.GetPosition(), //position of camera
transform.GetPosition() + transform.GetForward(), //position to look at
transform.GetUp()); //up vector
//return reference to the view matrix
return m_ViewMatrix;
}
Run Code Online (Sandbox Code Playgroud)
现在......这是我在Frame对象中的旋转X和Y方法,我猜这是问题所在:
void Frame::RotateX( float delta )
{
glm::vec3 cross = glm::normalize(glm::cross(m_Up, m_Forward)); //calculate x axis
glm::mat4 Rotation = glm::rotate(glm::mat4(1.0f), delta, cross);
m_Forward = glm::normalize(glm::vec3(Rotation …Run Code Online (Sandbox Code Playgroud) 正如Android文档所说:
对于除YV12之外的格式,缓冲区的大小通过将预览图像宽度,高度和每像素字节相乘来确定.可以从getPreviewSize()读取宽度和高度.可以getBitsPerPixel(int) / 8使用getPreviewFormat()的图像格式计算每像素的字节数.
但大多数在线代码使用bitsperpixel创建缓冲区而不是byteperpixel=bitsperpixel/8.
如果我使用下面的代码使用图像的确切大小(以字节为单位),将导致错误:E/Camera-JNI(3656):回调缓冲区太小了!预计1336320字节,但得到890880字节!这是为什么?为什么缓冲区需要8倍于图像大小?
Camera.Parameters parameters=mCamera.getParameters();
parameters.setPreviewSize(width,height);
mCamera.setParameters(parameters);
int previewFormat=parameters.getPreviewFormat();
int bitsperpixel=ImageFormat.getBitsPerPixel(previewFormat);
int byteperpixel=bitsperpixel/8;
Camera.Size camerasize=parameters.getPreviewSize();
int frame_bytesize=((camerasize.width*camerasize.height)*byteperpixel);
//create buffer
byte[]frameBuffer=new byte[frame_bytesize];
//buffer registry
mCamera.addCallbackBuffer(frameBuffer);
Run Code Online (Sandbox Code Playgroud) 我正在做相机应用程序.我有方形捕获和裁剪图像.但我需要椭圆形或人脸形状.它是怎么来的?
我想使用AVFoundation切换相机.这是我的代码我有NSObject的子类
@interface CaptureSessionManager : NSObject
@property (retain) AVCaptureVideoPreviewLayer *previewLayer;
@property (retain) AVCaptureSession *captureSession;
@property (retain) AVCaptureStillImageOutput *stillImageOutput;
@property (nonatomic, retain) UIImage *stillImage;
Run Code Online (Sandbox Code Playgroud)
在 @implementation CaptureSessionManager
- (id)init {
if ((self = [super init])) {
[self setCaptureSession:[[AVCaptureSession alloc] init]];
}
return self;
}
- (void)addVideoPreviewLayer {
[self setPreviewLayer:[[[AVCaptureVideoPreviewLayer alloc] initWithSession:[self captureSession]] autorelease]];
[[self previewLayer] setVideoGravity:AVLayerVideoGravityResizeAspectFill];
}
- (void)addVideoInputFrontCamera:(BOOL)front {
NSArray *devices = [AVCaptureDevice devices];
AVCaptureDevice *frontCamera;
AVCaptureDevice *backCamera;
for (AVCaptureDevice *device in devices) {
NSLog(@"Device name: %@", [device localizedName]);
if ([device …Run Code Online (Sandbox Code Playgroud)