Go to Post every year, Dean's speeches get better. in the process, he's also teaching people to be patient. - Winged Wonder [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-11-2016, 05:32 PM
SteveWozniakek SteveWozniakek is offline
Registered User
FRC #1369
 
Join Date: Feb 2016
Location: Tampa
Posts: 3
SteveWozniakek is an unknown quantity at this point
Flipping an image in NIVision

With NIVision I am trying to flip a camera image upside down. I currently have it as an Image type and do not see a NiVision method for rotating or flipping the image. Does anyone know how to flip the camera image in NIVision so I can send it to the CameraServer?
Reply With Quote
  #2   Spotlight this post!  
Unread 02-13-2016, 10:51 AM
koreamaniac101's Avatar
koreamaniac101 koreamaniac101 is offline
Founder and Team Leader
AKA: Soohan Kim
FRC #5938 (Razor Steel Robotics 4-H Club)
Team Role: Leadership
 
Join Date: Feb 2015
Rookie Year: 2016
Location: Dover, Delaware
Posts: 20
koreamaniac101 is an unknown quantity at this point
Re: Flipping an image in NIVision

Team 5938 is also looking for a solution to this as well. We have our Microsoft Lifecam mounted upside-down, and our drivers don't exactly like to go through the terrain with the floor on top.
Reply With Quote
  #3   Spotlight this post!  
Unread 02-13-2016, 03:55 PM
soundfx's Avatar
soundfx soundfx is offline
Registered User
AKA: Aaron J
FRC #3238 (Cyborg Ferrets)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2014
Location: Anacortes, WA
Posts: 14
soundfx is an unknown quantity at this point
Re: Flipping an image in NIVision

Have you looked at the imaqFlip method in NIVision?
Reply With Quote
  #4   Spotlight this post!  
Unread 02-17-2016, 06:37 AM
SteveWozniakek SteveWozniakek is offline
Registered User
FRC #1369
 
Join Date: Feb 2016
Location: Tampa
Posts: 3
SteveWozniakek is an unknown quantity at this point
Re: Flipping an image in NIVision

Yes I found the solution. I'll post a snippet later today for flipping it properly. Thanks for help though!
Reply With Quote
  #5   Spotlight this post!  
Unread 02-17-2016, 04:35 PM
Joey1939's Avatar
Joey1939 Joey1939 is offline
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 : 02-17-2016 at 04:44 PM.
Reply With Quote
  #6   Spotlight this post!  
Unread 02-17-2016, 07:35 PM
SteveWozniakek SteveWozniakek is offline
Registered User
FRC #1369
 
Join Date: Feb 2016
Location: Tampa
Posts: 3
SteveWozniakek is an unknown quantity at this point
Re: Flipping an image in NIVision

Your code is good but center axis needs to be vertical axis( I lied your knit cam wrong here's a snippet)
Quote:
camCenter = NIVision.IMAQdxOpenCamera("cam1", NIVision.IMAQdxCameraControlMode.CameraControlMode Controller);
camRight = NIVision.IMAQdxOpenCamera("cam0", NIVision.IMAQdxCameraControlMode.CameraControlMode Controller);
curCam = camCenter;
camera = "center";
// Img that will contain camera img
frame = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_ RGB, 0);
// Server that we'll give the img to
server = CameraServer.getInstance();
server.setQuality(50);
server.setSize(666);

Last edited by SteveWozniakek : 02-17-2016 at 07:38 PM.
Reply With Quote
  #7   Spotlight this post!  
Unread 02-17-2016, 07:51 PM
3205patriots 3205patriots is offline
Registered User
FRC #3205
 
Join Date: Jan 2016
Location: Concord
Posts: 6
3205patriots is an unknown quantity at this point
Re: Flipping an image in NIVision

I had this problem too and all you need to do to flip the image 180 degrees is

Image frame = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_ RGB, 0);

NIVision.imaqFlip(frame, frame, FlipAxis.HORIZONTAL_AXIS);
Reply With Quote
Reply


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 08:03 AM.

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