|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Getting BinaryImage write to work
Hi,
My team has tried using BinaryImage write() but could not get any files to appear in root dir on crio. I was playing with it a bit last night and eventually got images to appear. I have a few questions. Given something like: BinaryImage img = image.thresholdRGB(0, 40, 25, 255, 0, 40); 1- img.write("thresh.jpg"); did not work. img.write("/tmp/thresh.jpg"); did not work. img.write("/tmp/thresh.png") works. I did not try other file types. Not sure if writing a .png to / works or not... it was late and I was happy to get something working. Any ideas why using jpg does not work? Any reason writing to / may not work? I don't remember if I tried writing png to /. I am able to ftp the camera test sample jpg images to /. I did not try creating/writing to a text file yet. 2- the png image was either all black or had some red pixels/particles. We are using a green ring light. Our camera, RGB values, and filters need tuning but we should get something other than black/red. I looked in sunspotfrcsdk/lib/WPILibJ/src/edu/wpi/first/wpilibj/image/BinaryImage.java and found: Code:
public void write(String fileName) throws NIVisionException{
Pointer colorTable = new Pointer(1024);
//Black Background
colorTable.setByte(0, (byte)0); //B
colorTable.setByte(1, (byte)0); //G
colorTable.setByte(2, (byte)0); //R
colorTable.setByte(3, (byte)0); //Alpha
//Red Particles:
colorTable.setByte(4, (byte)0); //B
colorTable.setByte(5, (byte)0); //G
colorTable.setByte(6, (byte)255); //R
colorTable.setByte(7, (byte)0); //Alpha
try {
NIVision.writeFile(image, fileName, colorTable);
} finally {
colorTable.free();
}
}
Code:
colorTable.setByte(5, (byte)255); //G
colorTable.setByte(6, (byte)0); //R
-Maciej |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|