Added CVProcessor interface.
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package ve.ucv.ciens.ccg.nxtar;
|
package ve.ucv.ciens.ccg.nxtar;
|
||||||
|
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.interfaces.CVProcessor;
|
||||||
import ve.ucv.ciens.ccg.nxtar.interfaces.MulticastEnabler;
|
import ve.ucv.ciens.ccg.nxtar.interfaces.MulticastEnabler;
|
||||||
import ve.ucv.ciens.ccg.nxtar.interfaces.NetworkConnectionListener;
|
import ve.ucv.ciens.ccg.nxtar.interfaces.NetworkConnectionListener;
|
||||||
import ve.ucv.ciens.ccg.nxtar.interfaces.Toaster;
|
import ve.ucv.ciens.ccg.nxtar.interfaces.Toaster;
|
||||||
@@ -90,6 +91,7 @@ public class NxtARCore extends Game implements NetworkConnectionListener{
|
|||||||
|
|
||||||
// Assorted fields.
|
// Assorted fields.
|
||||||
public SpriteBatch batch;
|
public SpriteBatch batch;
|
||||||
|
public CVProcessor cvProc;
|
||||||
private Toaster toaster;
|
private Toaster toaster;
|
||||||
|
|
||||||
// Networking related fields.
|
// Networking related fields.
|
||||||
@@ -130,6 +132,13 @@ public class NxtARCore extends Game implements NetworkConnectionListener{
|
|||||||
Gdx.app.error(TAG, CLASS_NAME + ".Main() :: concreteApp does not implement MulticastEnabler. Quitting.");
|
Gdx.app.error(TAG, CLASS_NAME + ".Main() :: concreteApp does not implement MulticastEnabler. Quitting.");
|
||||||
Gdx.app.exit();
|
Gdx.app.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
|
this.cvProc = (CVProcessor)concreteApp;
|
||||||
|
}catch(ClassCastException cc){
|
||||||
|
Gdx.app.error(TAG, CLASS_NAME + ".Main() :: concreteApp does not implement the CVProcessor interface. Quitting.");
|
||||||
|
Gdx.app.exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void create(){
|
public void create(){
|
||||||
|
26
src/ve/ucv/ciens/ccg/nxtar/interfaces/CVProcessor.java
Normal file
26
src/ve/ucv/ciens/ccg/nxtar/interfaces/CVProcessor.java
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Miguel Angel Astor Romero
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package ve.ucv.ciens.ccg.nxtar.interfaces;
|
||||||
|
|
||||||
|
public interface CVProcessor {
|
||||||
|
public class CVData{
|
||||||
|
public byte[] outFrame;
|
||||||
|
public int[] markerCodes;
|
||||||
|
// TODO: Add marker location data.
|
||||||
|
}
|
||||||
|
|
||||||
|
public CVData processFrame(byte[] frame, int w, int h);
|
||||||
|
}
|
@@ -21,6 +21,7 @@ import ve.ucv.ciens.ccg.networkdata.MotorEvent;
|
|||||||
import ve.ucv.ciens.ccg.networkdata.MotorEvent.motor_t;
|
import ve.ucv.ciens.ccg.networkdata.MotorEvent.motor_t;
|
||||||
import ve.ucv.ciens.ccg.nxtar.NxtARCore;
|
import ve.ucv.ciens.ccg.nxtar.NxtARCore;
|
||||||
import ve.ucv.ciens.ccg.nxtar.NxtARCore.game_states_t;
|
import ve.ucv.ciens.ccg.nxtar.NxtARCore.game_states_t;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.interfaces.CVProcessor.CVData;
|
||||||
import ve.ucv.ciens.ccg.nxtar.network.monitors.MotorEventQueue;
|
import ve.ucv.ciens.ccg.nxtar.network.monitors.MotorEventQueue;
|
||||||
import ve.ucv.ciens.ccg.nxtar.network.monitors.VideoFrameMonitor;
|
import ve.ucv.ciens.ccg.nxtar.network.monitors.VideoFrameMonitor;
|
||||||
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
||||||
@@ -152,9 +153,11 @@ public class InGameState extends BaseState{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(float delta){
|
public void render(float delta){
|
||||||
|
int fW, fH;
|
||||||
byte[] frame;
|
byte[] frame;
|
||||||
byte[] prevFrame = null;
|
byte[] prevFrame = null;
|
||||||
Size dimensions = null;
|
Size dimensions = null;
|
||||||
|
CVData data;
|
||||||
|
|
||||||
Gdx.gl.glClearColor(1, 1, 1, 1);
|
Gdx.gl.glClearColor(1, 1, 1, 1);
|
||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||||
@@ -170,9 +173,20 @@ public class InGameState extends BaseState{
|
|||||||
}core.batch.end();
|
}core.batch.end();
|
||||||
|
|
||||||
frame = frameMonitor.getCurrentFrame();
|
frame = frameMonitor.getCurrentFrame();
|
||||||
if(frame != null && !Arrays.equals(frame, prevFrame)){
|
fW = frameMonitor.getFrameDimensions().getWidth();
|
||||||
|
fH = frameMonitor.getFrameDimensions().getHeight();
|
||||||
|
|
||||||
|
data = core.cvProc.processFrame(frame, fW, fH);
|
||||||
|
|
||||||
|
if(data != null){
|
||||||
|
for(int i = 0; i < data.markerCodes.length; i++){
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + String.format(".render(): Marker code[%d] = %d", i, data.markerCodes[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(data != null && data.outFrame != null && !Arrays.equals(frame, prevFrame)){
|
||||||
dimensions = frameMonitor.getFrameDimensions();
|
dimensions = frameMonitor.getFrameDimensions();
|
||||||
videoFrame = new Pixmap(frame, 0, dimensions.getWidth() * dimensions.getHeight());
|
videoFrame = new Pixmap(data.outFrame, 0, dimensions.getWidth() * dimensions.getHeight());
|
||||||
videoFrameTexture = new Texture(videoFrame);
|
videoFrameTexture = new Texture(videoFrame);
|
||||||
videoFrameTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
|
videoFrameTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
|
||||||
videoFrame.dispose();
|
videoFrame.dispose();
|
||||||
|
Reference in New Issue
Block a user