Skip to content

Commit

Permalink
* Expose apiPreference constructor argument of VideoCapture to `…
Browse files Browse the repository at this point in the history
…OpenCVFrameGrabber` (pull #1025)
  • Loading branch information
kwatters authored and saudet committed Jul 3, 2018
1 parent f8b5026 commit a57084e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/main/java/org/bytedeco/javacv/OpenCVFrameGrabber.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,17 @@ public OpenCVFrameGrabber(int deviceNumber) {
public OpenCVFrameGrabber(File file) {
this(file.getAbsolutePath());
}
public OpenCVFrameGrabber(File file, int apiPreference) {
this(file.getAbsolutePath(), apiPreference);
}
public OpenCVFrameGrabber(String filename) {
this.filename = filename;
}
public OpenCVFrameGrabber(String filename, int apiPreference) {
this.filename = filename;
this.apiPreference = apiPreference;
}

public void release() throws Exception {
stop();
}
Expand All @@ -76,6 +84,7 @@ public void release() throws Exception {

private int deviceNumber = 0;
private String filename = null;
private int apiPreference = 0;
private VideoCapture capture = null;
private Mat returnMatrix = null;
private final OpenCVFrameConverter converter = new OpenCVFrameConverter.ToMat();
Expand Down Expand Up @@ -171,7 +180,11 @@ public void release() throws Exception {

public void start() throws Exception {
if (filename != null && filename.length() > 0) {
capture = new VideoCapture(filename);
if (apiPreference > 0) {
capture = new VideoCapture(filename, apiPreference);
} else {
capture = new VideoCapture(filename);
}
} else {
capture = new VideoCapture(deviceNumber);
}
Expand Down

0 comments on commit a57084e

Please sign in to comment.