Finish crop mods, fix config #6
5 changed files with 14 additions and 49 deletions
13
README.md
13
README.md
|
@ -52,15 +52,20 @@ sudo systemctl disable pigpiod
|
|||
The first command stops all currently running `pigpio` daemon processes. The second command disables the daemon, so that it will not start again if you reboot.
|
||||
|
||||
2. You will need to create a new `udev` rule. This creates a symlink for a given camera, plugged into a specific USB port, and allows the Java code to consistently communicate with the camera. An example `udev` rule is given in this repo (`83-webcam.rules`), but will need to be modified to your specific device.
|
||||
1. Copy the example `udev` rule file to your Raspberry Pi, and put it in `/etc/udev/rules.d/` (if this directory does not exist, create it). It is recommended to do this in the terminal, by running the following commands:
|
||||
1. Copy the example `udev` rule file to your Raspberry Pi, and put it in `/etc/udev/rules.d/` (if this directory does not exist, create it). This is done by running the followwing command in the terminal.
|
||||
|
||||
```bash
|
||||
sudo cp /media/pi/[flash drive]/83-webcam.rules /etc/udev/rules.d/
|
||||
```
|
||||
|
||||
This is a soft-requirement, as interacting with files in this location requires administrative privileges.
|
||||
Replace the `[flash drive]` portion of the above line with the name of your flash drive.
|
||||
Alternatively, you can go to your flash drive in the File Manager, and press the `F4` key to open a terminal in that location. Then, enter the following command:
|
||||
|
||||
2. Open the copied file in the text editor of your choice, and open a terminal window as well. It is recommended to do this by running the following command in a terminal:
|
||||
```bash
|
||||
sudo cp 83-webcam.rules /etc/udev/rules.d/
|
||||
```
|
||||
|
||||
2. Open the copied file in the text editor of your choice, and open a terminal window as well. This is done easiest by running the following command in a terminal:
|
||||
|
||||
```bash
|
||||
sudo -e /etc/udev/rules.d/83-webcam.rules
|
||||
|
@ -68,7 +73,7 @@ The first command stops all currently running `pigpio` daemon processes. The sec
|
|||
|
||||
This will open a terminal-based text editor, crucially, *as an admin*, which will allow you to save the file.
|
||||
|
||||
3. Run the following command in your terminal window.
|
||||
3. Run the following command in a second terminal window.
|
||||
|
||||
```bash
|
||||
sudo udevadm monitor -p | grep ID_PATH=
|
||||
|
|
|
@ -697,7 +697,7 @@ public class Cli
|
|||
for(int i = 0; i < localIterations; i++)
|
||||
{
|
||||
println("");
|
||||
println("====================================");
|
||||
ErrorLogging.logError("====================================");
|
||||
ErrorLogging.logError("Starting iteration " + (i+1) + " of " + localIterations + "...");
|
||||
while(!LOCK.tryLock()) {}
|
||||
fixture.iterationMovement(prime);
|
||||
|
|
|
@ -335,8 +335,8 @@ public class ConfigFacade
|
|||
{
|
||||
for(ConfigProperties property : ConfigProperties.values())
|
||||
{
|
||||
String propertyName = camera + "." + property.toString();
|
||||
String propertyValue =configMap.get(camera).get(property).toString();
|
||||
String propertyName = camera + "." + property.getConfig();
|
||||
String propertyValue = configMap.get(camera).get(property).toString();
|
||||
CONFIG_STORE.setProperty(propertyName,propertyValue);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,9 +69,9 @@ public enum ConfigProperties
|
|||
private ConfigProperties(String print, String config, double defaultValue) { this.print = print; this.config = config; this.defaultValue = defaultValue; }
|
||||
|
||||
/**
|
||||
* Getter for the config-readable name of the value.
|
||||
* Getter for the default value for this config property
|
||||
*
|
||||
* @return String of the name of the value.
|
||||
* @return double of the default value
|
||||
*/
|
||||
public double getDefaultValue()
|
||||
{ return defaultValue; }
|
||||
|
|
|
@ -280,46 +280,6 @@ public class OpenCVFacade
|
|||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crop the given image to the dimensions in the configuration;
|
||||
* deprecated in favour of {@link #crop(Mat, Rect)}
|
||||
*
|
||||
* @deprecated
|
||||
* @param image Frame taken from the camera.
|
||||
* @param cameraName Name of the camera taking the picture
|
||||
*
|
||||
* @return Frame of the cropped image
|
||||
*/
|
||||
private static Mat cropImage(Mat image, String cameraName)
|
||||
{
|
||||
Mat output = null;
|
||||
int x = (int)ConfigFacade.getValue(cameraName,ConfigProperties.CROP_X);
|
||||
int y = (int)ConfigFacade.getValue(cameraName,ConfigProperties.CROP_Y);
|
||||
int width = (int)ConfigFacade.getValue(cameraName,ConfigProperties.CROP_W);
|
||||
int height = (int)ConfigFacade.getValue(cameraName,ConfigProperties.CROP_H);
|
||||
//ErrorLogging.logError("DEBUG: Crop dimensions:");
|
||||
//ErrorLogging.logError("DEBUG: X = " + x);
|
||||
//ErrorLogging.logError("DEBUG: Y = " + y);
|
||||
//ErrorLogging.logError("DEBUG: Width = " + width);
|
||||
//ErrorLogging.logError("DEBUG: Height = " + height);
|
||||
//ErrorLogging.logError("DEBUG: Original image size: ");
|
||||
//ErrorLogging.logError("DEBUG: Width: " + image.cols());
|
||||
//ErrorLogging.logError("DEBUG: Height: " + image.rows());
|
||||
|
||||
IplImage temp = MAT_CONVERTER.convertToIplImage(MAT_CONVERTER.convert(image));
|
||||
CvRect crop = new CvRect();
|
||||
crop.x(x); crop.y(y); crop.width(width); crop.height(height);
|
||||
cvSetImageROI(temp,crop);
|
||||
IplImage croppedImage = cvCreateImage(cvGetSize(temp), temp.depth(),temp.nChannels());
|
||||
cvCopy(temp,croppedImage);
|
||||
output = MAT_CONVERTER.convert(MAT_CONVERTER.convert(croppedImage));
|
||||
//Old code; Throws runtime exception - Failed assertion that all inputs are safe. Not entirely sure why though.
|
||||
//var cropRectangle = new Rect(x,y,width,height);
|
||||
//output = image.apply(cropRectangle);
|
||||
////output = new Mat(image,cropRectangle);
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put the given image through a binary threshold.
|
||||
* This reduces the image from greyscale to only pure white and black pixels.
|
||||
|
|
Loading…
Add table
Reference in a new issue