Skip to content

Commit

Permalink
Colour filtering ui
Browse files Browse the repository at this point in the history
  • Loading branch information
ktg committed Mar 3, 2016
1 parent c03924c commit 9c00b12
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 65 deletions.
14 changes: 7 additions & 7 deletions artcodes-android.iml
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,20 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/.DS_Store" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import android.util.Log;
import android.view.View;

import org.opencv.android.OpenCVLoader;
import org.opencv.core.Rect;

import uk.ac.horizon.artcodes.model.Experience;
Expand All @@ -35,14 +34,6 @@

public class ArtcodeDetector extends Detector
{
static
{
if (!OpenCVLoader.initDebug())
{
Log.e("OpenCV", "Error Initializing OpenCV");
}
}

private int margin = 100;

@BindingAdapter("height")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.graphics.Bitmap;
import android.util.Log;

import org.opencv.android.OpenCVLoader;
import org.opencv.core.Rect;

import java.util.ArrayList;
Expand All @@ -35,6 +36,14 @@

public class Detector extends BaseObservable
{
static
{
if (!OpenCVLoader.initDebug())
{
Log.e("OpenCV", "Error Initializing OpenCV");
}
}

protected final List<ImageProcessor> pipeline = new ArrayList<>();
protected final List<DetectorSetting> settings = new ArrayList<>();
protected final ImageBuffers buffers = new ImageBuffers();
Expand Down Expand Up @@ -123,6 +132,6 @@ public byte[] createBuffer(CameraInfo info, int surfaceWidth, int surfaceHeight)

protected Rect createROI(int imageWidth, int imageHeight, int surfaceWidth, int surfaceHeight)
{
return null;
return new Rect(0, 0, imageWidth, imageHeight);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public void process(ImageBuffers buffers)
Imgproc.cvtColor(buffers.getTemp(), buffers.getImage(), Imgproc.COLOR_BGR2GRAY);
}

public Channel getChannel()
{
return channel;
}

@Override
public void getSettings(List<DetectorSetting> settings)
{
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ android {

defaultConfig {
applicationId "uk.ac.horizon.aestheticodes"
versionName '3.1.1'
versionCode 400051
versionName '3.1.2'
versionCode 400052
minSdkVersion 15
targetSdkVersion 23
signingConfig signingConfigs.release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,21 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import uk.ac.horizon.artcodes.R;
import uk.ac.horizon.artcodes.databinding.ExperienceEditColourBinding;
import uk.ac.horizon.artcodes.detect.Detector;
import uk.ac.horizon.artcodes.detect.ImageBuffers;
import uk.ac.horizon.artcodes.process.ImageProcessor;
import uk.ac.horizon.artcodes.process.RGBGreyscaler;

public class ExperienceEditColourFragment extends ExperienceEditFragment
{
private final Object lockObject = new Object();
private final List<ImageProcessor> presets = new ArrayList<>();
private final ImageBuffers buffers = new ImageBuffers();
private ExperienceEditColourBinding binding;
private ImageProcessor filter;
private Detector detector;

@Override
public int getTitleResource()
{
Expand All @@ -53,41 +49,69 @@ public int getTitleResource()
@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
binding = ExperienceEditColourBinding.inflate(inflater, container, false);
// scanner = new Scanner(getActivity());
//
// binding.cameraSurface.getHolder().addCallback(scanner);
// binding.setBuffers(buffers);
//
// //presets.add(new IntensityGreyscaler());
// presets.add(new RGBGreyscaler(RGBGreyscaler.Channel.red));
// presets.add(new RGBGreyscaler(RGBGreyscaler.Channel.green));
// presets.add(new RGBGreyscaler(RGBGreyscaler.Channel.blue));
// // TODO Add cmy/cmyk/custom?
//
// detector = new Detector(buffers);
// scanner.setFrameProcessor(detector);
//
// binding.colourPresetSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
// {
// @Override
// public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l)
// {
// //String[] names = getResources().getStringArray(R.array.colourPresetNames);
// if (i < presets.size())
// {
// synchronized (lockObject)
// {
// //experience.setGreyscaleOptions(presets.get(i));
// }
// }
// }
//
// @Override
// public void onNothingSelected(AdapterView<?> adapterView)
// {
// }
// });
final ExperienceEditColourBinding binding = ExperienceEditColourBinding.inflate(inflater, container, false);

final List<ImageProcessor> presets = new ArrayList<>();
// TODO presets.add(new IntensityGreyscaler());
presets.add(new RGBGreyscaler(RGBGreyscaler.Channel.red));
presets.add(new RGBGreyscaler(RGBGreyscaler.Channel.green));
presets.add(new RGBGreyscaler(RGBGreyscaler.Channel.blue));

final Detector detector = new Detector();
binding.setDetector(detector);

binding.colourPresetSpinner.setAdapter(new BaseAdapter()
{
@Override
public int getCount()
{
return presets.size();
}

@Override
public Object getItem(final int position)
{
return presets.get(position);
}

@Override
public long getItemId(final int position)
{
return 0;
}

@Override
public View getView(final int position, final View convertView, final ViewGroup parent)
{
View view = convertView;
if(!(view instanceof TextView))
{
view = new TextView(parent.getContext());
}

ImageProcessor processor = presets.get(position);
if(processor instanceof RGBGreyscaler)
{
((TextView)view).setText(((RGBGreyscaler)processor).getChannel().toString());
}


return view;
}
});
binding.colourPresetSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l)
{
// TODO
}

@Override
public void onNothingSelected(AdapterView<?> adapterView)
{
}
});

return binding.getRoot();
}
Expand Down
14 changes: 11 additions & 3 deletions src/main/res/layout/experience_edit_colour.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,34 @@

<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".activities.ExperienceEditActivity">

<data>

<import type="android.view.View"/>

<variable
name="detector"
type="uk.ac.horizon.artcodes.detect.Detector"/>
</data>

<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">

<SurfaceView
android:id="@+id/cameraSurface"
<uk.ac.horizon.artcodes.camera.CameraView
android:id="@+id/cameraView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
android:layout_height="fill_parent"
app:detector="@{detector}"/>

<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
app:imageBitmap="@{detector.overlay}"
tools:ignore="ContentDescription"/>

<LinearLayout
Expand Down

0 comments on commit 9c00b12

Please sign in to comment.