Go to Post P.S. Who doesn't have CD as there homepage! (I mean, come on people. It's not like there's anything else to do on the net... :)) - Ryan M. [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Spotlight this post!  
Unread 17-02-2016, 16:35
Joey1939's Avatar
Joey1939 Joey1939 is online now
Registered User
AKA: Joey Holliday
FRC #1939 (Kuhnigits)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Kansas City, Missouri
Posts: 139
Joey1939 has a spectacular aura aboutJoey1939 has a spectacular aura aboutJoey1939 has a spectacular aura about
Re: Flipping an image in NIVision

Can you please post the code that you used to do this? My team has mounted the camera upside down, and I need to flip the image in code. I couldn't find any documentation on NIVision, and I would appreciate any help.

I am using Java and this is my current command, which is set to run while the robot is disabled. It currently doesn't correctly send an image to the SmartDashboard and throws and exception occasionally.
Code:
package org.usfirst.frc.team1939.robot.commands.camera;

import org.usfirst.frc.team1939.robot.Robot;

import com.ni.vision.NIVision;
import com.ni.vision.NIVision.FlipAxis;
import com.ni.vision.NIVision.Image;
import com.ni.vision.NIVision.ImageType;

import edu.wpi.first.wpilibj.CameraServer;
import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.vision.USBCamera;

public class CameraUpdater extends Command {

	private USBCamera camera;
	private CameraServer server;

	public CameraUpdater() {
		requires(Robot.camera);
	}

	@Override
	protected void initialize() {
		this.camera = new USBCamera("cam0");
		this.server = CameraServer.getInstance();
		this.camera.startCapture();
	}

	@Override
	protected void execute() {
		Image source = NIVision.imaqCreateImage(ImageType.IMAGE_RGB, 0);
		this.camera.getImage(source);
		Image dest = NIVision.imaqCreateImage(ImageType.IMAGE_RGB, 0);
		NIVision.imaqFlip(dest, source, FlipAxis.CENTER_AXIS);
		this.server.setImage(dest);
	}

	@Override
	protected boolean isFinished() {
		return false;
	}

	@Override
	protected void end() {
	}

	@Override
	protected void interrupted() {
	}
}
__________________



Last edited by Joey1939 : 17-02-2016 at 16:44.
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 18:49.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi