Go to Post Come on guys, its not like it's rocket surgery or anything. - hallk [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
  #1   Spotlight this post!  
Unread 03-31-2016, 10:10 AM
richtop richtop is offline
Registered User
AKA: Richard Topolewski
FRC #5053 (Laker Robotics)
Team Role: Mentor
 
Join Date: Nov 2014
Rookie Year: 2013
Location: Waterford, Michigan
Posts: 16
richtop is an unknown quantity at this point
How to lower image pixels in straight NIVision code.

Okay we have had camera working at our tournaments, and have added laptop side processing in the Labview dashboard of the image to get the alignment to the goal, which is sent back to the roborio.

At first we were using the following code to send the image.
camera = CameraServer.getInstance();
camera.setSize(2/*camera.kSize320x240*/);
camera.setImage(Image.SCALE_FAST);
camera.setQuality(100);
camera.startAutomaticCapture("cam0");


But we were running 90% to 100% pegged CPU.

By changing to the following code it now is running a more reasonable 40% to 60% CPU. But we are only getting 1.9 frame per second. I would like to lower the pixels in the picture, but don't know the how to in straight NIVision code. Any pointers in the right direction would be appreciated.


public class Robot extends IterativeRobot {
...
...
int countToTakePicture = 20;
int currentCountToTakePicture = 0;
...
...
public void teleopPeriodic() {
Scheduler.getInstance().run();
boolean takePicture = false;
if(currentCountToTakePicture == countToTakePicture){
takePicture = true;
}
else if(currentCountToTakePicture <= countToTakePicture){
currentCountToTakePicture++;
} else {
currentCountToTakePicture = 0;
}

if (takePicture){
int session;
session = NIVision.IMAQdxOpenCamera("cam0",NIVision.IMAQdxCa meraControlMode.CameraControlModeController);
NIVision.IMAQdxStartAcquisition(session);
Image frame = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_ RGB, 0);
NIVision.IMAQdxGrab(session, frame, 10);
cameraServer.getInstance().setImage(frame);
NIVision.IMAQdxStopAcquisition(session);
NIVision.IMAQdxCloseCamera(session);

// from cheifdelphi Program crashes with out of memory issue if we remove this line
frame.free();
}



Lower priority items:
Also should probably do a more controlled way on when to take the picture.

Also thinking about copying it into auton so can autoalign for our low goal, I dont anticipate any problems but, my lack of full understanding of NIVision makes me worry, should I?
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 07:27 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