Skip to content

Commit

Permalink
Fix android Paint to actually clone old native Paint in constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
serivesmejia committed Jul 1, 2024
1 parent 29219b5 commit ae44b93
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ class EOCVSim(val params: Parameters = Parameters()) {
)
}


updateVisualizerTitle() // update current pipeline in title
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class EOCVSimCommandInterface : Runnable {
parameters.initialPipelineSource = initialPipelineSource
}


if (opencvNativePath != null) {
parameters.opencvNativeLibrary = checkPath("OpenCV Native", opencvNativePath!!, false)
}
Expand Down
2 changes: 1 addition & 1 deletion Vision/src/main/java/android/graphics/Paint.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public Paint() {
}

public Paint(Paint paint) {
thePaint = paint.thePaint;
thePaint = paint.thePaint.makeClone();

typeface = paint.typeface;
textSize = paint.textSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
package io.github.deltacv.vision.external;

import io.github.deltacv.vision.external.source.VisionSource;
import io.github.deltacv.vision.external.source.VisionSourced;
import io.github.deltacv.vision.external.source.FrameReceiver;
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Size;
import org.openftc.easyopencv.*;

public class SourcedOpenCvCamera extends OpenCvCameraBase implements OpenCvWebcam, VisionSourced {
public class SourcedOpenCvCamera extends OpenCvCameraBase implements OpenCvWebcam, FrameReceiver {

private final VisionSource source;
OpenCvViewport handedViewport;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import org.opencv.core.Mat;

public interface VisionSourced {
public interface FrameReceiver {

default void onFrameStart() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public interface VisionSource {

boolean start(Size requestedSize);

boolean attach(VisionSourced sourced);
boolean remove(VisionSourced sourced);
boolean attach(FrameReceiver sourced);
boolean remove(FrameReceiver sourced);

boolean stop();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Arrays;

public abstract class VisionSourceBase implements VisionSource {

private final Object lock = new Object();

ArrayList<VisionSourced> sourceds = new ArrayList<>();
ArrayList<FrameReceiver> sourceds = new ArrayList<>();

SourceBaseHelperThread helperThread;

Expand All @@ -61,14 +60,14 @@ public final boolean start(Size size) {
public abstract boolean startSource(Size size);

@Override
public boolean attach(VisionSourced sourced) {
public boolean attach(FrameReceiver sourced) {
synchronized (lock) {
return sourceds.add(sourced);
}
}

@Override
public boolean remove(VisionSourced sourced) {
public boolean remove(FrameReceiver sourced) {
synchronized (lock) {
return sourceds.remove(sourced);
}
Expand All @@ -88,7 +87,7 @@ public final boolean stop() {
public abstract Timestamped<Mat> pullFrame();

private Timestamped<Mat> pullFrameInternal() {
for(VisionSourced sourced : sourceds) {
for(FrameReceiver sourced : sourceds) {
synchronized (sourced) {
sourced.onFrameStart();
}
Expand Down Expand Up @@ -116,7 +115,7 @@ public SourceBaseHelperThread(VisionSourceBase sourcedBase, ThrowableHandler thr

@Override
public void run() {
VisionSourced[] sourceds = new VisionSourced[0];
FrameReceiver[] sourceds = new FrameReceiver[0];

logger.info("starting");

Expand All @@ -134,10 +133,10 @@ public void run() {
}

synchronized (sourceBase.lock) {
sourceds = sourceBase.sourceds.toArray(new VisionSourced[0]);
sourceds = sourceBase.sourceds.toArray(new FrameReceiver[0]);
}

for (VisionSourced sourced : sourceds) {
for (FrameReceiver sourced : sourceds) {
try {
sourced.onNewFrame(frame.getValue(), frame.getTimestamp());
} catch(Throwable e) {
Expand All @@ -150,7 +149,7 @@ public void run() {
}
}

for(VisionSourced sourced : sourceds) {
for(FrameReceiver sourced : sourceds) {
sourced.stop();
}

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ plugins {

allprojects {
group 'com.github.deltacv'
version '3.5.3'
version '3.5.4'

apply plugin: 'java'

Expand Down

0 comments on commit ae44b93

Please sign in to comment.