i HAVE STARTED A NEW video STREAM PROJECT USING java LANGUAGE .I will put you in the scope of my two questions but keep know now that I will ask you about vedio capturing and detection ,not sending videos .
1-I have downloaded the jmf studio and registry . the problem in the jmf regestry .jfm registry cannot detect my pc cam .how can i detect it, or as i read in other words , where the jmf.properties can be put to run the registry well.
2- as i go forward to write the java code , i used this code to detect the cam:
Vector<CaptureDeviceInfo> list = CaptureDeviceManager.getDeviceList ( new
YUVFormat() );
// Iterating list
for(CaptureDeviceInfo temp : list){
// Checking whether the current device supports VfW
// VfW = Video for Windows
if(temp.getName().startsWith("vfw:")){
System.out.println("Found :
"+temp.getName().substring(4));// Selecting the very first device that supports VfW
cam = temp;
System.out.println("Selected :
"+cam.getName().substring(4));
break;
}
}
System.out.println("Put it on work!...");
// Getting the MediaLocator for Selected device.
// MediaLocator describes the location of media content
locator = cam.getLocator();///
this is just a snap shot, look now ,as no device can be detected the locator stay null, now my question is there a realation between the jmf registry and in general any project that will use this function to detect devices. sorry for this long question .
note : as i try all the answers of this question which i have founded on the stack overflow or others with no success , i have been forced to ask it a gain .
Related
Why isOperational() in mobile vision text recognizer returns false?
At first, mobile vision only show preview camera and after many tries to get the result, I saw that the texts recognized but in one device it works and in other device does not.
What should I do?
For example, in one device, isOperational() returns false, and it goes to readstate() and after that goes to looper() and stays on it!
in other device it only return false and doesn't go to looper.
I want ask other questions about it:
My first question is: how does isOperational() work? I can't understand it.
Maybe it goes to looper to download the native library in a queue and after many try, at last download completes and work. Can it be correct? Or is it just a bug that it goes to looper? Anywhere, what should I do?
Can I work on this when it works in one device I tried and in other does not? Or it must work in every device to I can work on it? And I get .apk from project but it can't install in devices, why?
Should it check for network?
Should it check for access to the memory?
note: it works with camera API and its deprecated. maybe the problem is with this!
TextRecognizer textRecognizer = new TextRecognizer.Builder(context).build();
textRecognizer.setProcessor(new OcrDetectorProcessor(graphicOverlay));
if (!textRecognizer.**isOperational**()) {
// Note: The first time that an app using a Vision API is installed on a
// device, GMS will download a native libraries to the device in order to do detection.
// Usually this completes before the app is run for the first time. But if that
// download has not yet completed, then the above call will not detect any text,
// barcodes, or faces.
//
// isOperational() can be used to check if the required native libraries are currently
// available. The detectors will automatically become operational once the library
// downloads complete on device.
Log.w(TAG, "Detector dependencies are not yet available.");
// Check for low storage. If there is low storage, the native library will not be
// downloaded, so detection will not become operational.*
IntentFilter lowstorageFilter = new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW);
boolean hasLowStorage = registerReceiver(null, lowstorageFilter) != null;
if (hasLowStorage) {
Toast.makeText(this, R.string.low_storage_error, Toast.LENGTH_LONG).show();
Log.w(TAG, getString(R.string.low_storage_error));
}
}
*// Creates and starts the camera. Note that this uses a higher resolution in comparison
// to other detection examples to enable the text recognizer to detect small pieces of text.*
cameraSource =
new CameraSource.Builder(getApplicationContext(), textRecognizer)
.setFacing(CameraSource.CAMERA_FACING_BACK)
.setRequestedPreviewSize(1280, 1024)
.setRequestedFps(2.0f)
.setFlashMode(useFlash ? Camera.Parameters.FLASH_MODE_TORCH : null)
.setFocusMode(autoFocus ? Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO : null)
.build();
}
It doesn't produce any error and show preview camera but doesn't recognize texts in some devices.
UPDATE:
I found the lines for re-localization, but de the device doesn't localize itself. I always get the status code POSE_INITIALIZING back after loading the ADF. Also the re-localization in the Java Area_Description_Example doesn't work. Anyone with the same problem?
The only apps with working re-localozation are "Explorer" and "ADF Inspector", but I don't have the source code for it.
Here is the solution of my first question, the code to check re-localization after loading an ADF:
TangoPoseData lastFramePose = mTango.getPoseAtTime(mRgbTimestampGlThread,
FRAME_PAIR);
if (lastFramePose.statusCode == TangoPoseData.POSE_VALID) {
// Device is re-located!
// Update the camera pose from the renderer
mRenderer.updateRenderCameraPose(lastFramePose);
mCameraPoseTimestamp = lastFramePose.timestamp;
} else {
Log.w(TAG, "Can't get device pose at time: " + mRgbTimestampGlThread);
}
OLD:
In my application the user can decide whether to start a new session or load an previously recorded ADF (area description file). I loaded the ADF (adfUUID) and added it to the Tango class object (mTango) like below:
TangoConfig config = mTango.getConfig(TangoConfig.CONFIG_TYPE_CURRENT);
config.putString(TangoConfig.KEY_STRING_AREADESCRIPTION, adfUUID);
mTango.setRuntimeConfig(config);
So my question is now, how can I check if the area is localized with the loaded ADF? I want to have a coordinate reference frame to the start of service of the loaded ADF and not of my new session.
This are my settings in my connectTango() function:
TangoConfig config = mTango.getConfig(TangoConfig.CONFIG_TYPE_DEFAULT);
config.putBoolean(TangoConfig.KEY_BOOLEAN_LOWLATENCYIMUINTEGRATION, true);
config.putBoolean(TangoConfig.KEY_BOOLEAN_DEPTH, true);
config.putBoolean(TangoConfig.KEY_BOOLEAN_LEARNINGMODE, true);
config.putBoolean(TangoConfig.KEY_BOOLEAN_COLORCAMERA, true);
mTango.connect(config);
And the fram pair I used is:
private static final TangoCoordinateFramePair FRAME_PAIR = new TangoCoordinateFramePair(
TangoPoseData.COORDINATE_FRAME_AREA_DESCRIPTION,
TangoPoseData.COORDINATE_FRAME_DEVICE);
Both "Loaded ADF on with Learning mode on" and "Load ADF on with Learning mode off" are Good.
Currently They are using different location pipeline.
So the first one will take much longer time localized than the second ones.
ADF Inspector is for Load ADF on with Learning off"
Tango Explorer should be Re-localized with with "Load ADF on with Learning on"
for question about how to check the ADF localized please see the example java code:
// Check for Device wrt ADF pose, Device wrt Start of Service pose,
// Start of Service wrt ADF pose (This pose determines if the device
// is relocalized or not).
if (pose.baseFrame == TangoPoseData.COORDINATE_FRAME_AREA_DESCRIPTION
&& pose.targetFrame == TangoPoseData
.COORDINATE_FRAME_START_OF_SERVICE) {
if (pose.statusCode == TangoPoseData.POSE_VALID) {
mIsRelocalized = true;
} else {
mIsRelocalized = false;
}
Pose Data on the third ones:
ArrayList<TangoCoordinateFramePair> framePairs = new ArrayList<TangoCoordinateFramePair>();
framePairs.add(new TangoCoordinateFramePair(
TangoPoseData.COORDINATE_FRAME_START_OF_SERVICE,
TangoPoseData.COORDINATE_FRAME_DEVICE));
framePairs.add(new TangoCoordinateFramePair(
TangoPoseData.COORDINATE_FRAME_AREA_DESCRIPTION,
TangoPoseData.COORDINATE_FRAME_DEVICE));
framePairs.add(new TangoCoordinateFramePair(
TangoPoseData.COORDINATE_FRAME_AREA_DESCRIPTION,
TangoPoseData.COORDINATE_FRAME_START_OF_SERVICE));
I found some pretty similiar questions on the same topic here:
1. question
2. question
3. question
4. question
So I think the answer is the following:
Re-localization with an loaded ADF and learning mode on works, but it takes quite a while (up to 3-5 minutes). Walk around and don't give up.
Re-localization with an loaded ADF and learning mode off works.
What have I done so far:
I am currenctly facing some problems with the launchers.
My application adds shortcuts to the workspace of the launcher (homescreen).
But on some devices (Samsum Duos) for example, the titles and /or icons
are changed back after reboot to my default application one.
So I am currently going through 1000s of lines code in the android
source to identify the problem, but was not able to find it.
I saw in InstallShortcutReceiver
a comment in line 183 that the "name" provided by Intent.EXTRA_SHORTCUT_NAME can in
some situations be used only for comparison etc and will be replaced
with the applications default name.
// This name is only used for comparisons and notifications, so fall back to activity name
// if not supplied
But (my Samsum Duos is rooted) I could find the complete information's
about the cell position and shortcutInfo's inside of the launcher.db.
So it was not gone, after reboot, but maybe only not correct initialized!
First Question:
Does anybody know the reason for a custom, programmatically created shortcut to change the title and or icon back to the application's one that created it?
Next story:
I noticed that this issue was reproducible on my Samsum Duos, so I decided
to exclude the Devices Launcher from my "save launcher" list.
To receive the default launcher I am doing the following:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
ResolveInfo resolveInfo = null;
try {
resolveInfo = context.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); //can return null!
}catch(RuntimeException e){
ExceptionHandler.logAndSendException(e);//package manager has died
return false;
}
But the problem now is, that it always returns that the default launchers
package is: com.android.launcher2.Launcher, which would be the standard
android stock launcher. But I know that Samsum uses the TouchWiz home
launcher, whos Package is located under com.sec.android.app.launcher!
That is also where I found the launcher.db and all its ShortcutInfo's.
2. Second Question
How do I get reproducible the correct default launcher package to identify
which launcher is used?
edit:
I kind of fixed the second problem. Somehow the ResolveInfo I get from
the PackageManager seems to be not reliable.
For the Samsum Duos I get:
resolveInfo.activityInfo.name = com.android.launcher2.Launcher
resolveInfo.activityInfo.packageName = com.sec.android.app.launcher //this is what I need
But for the Redmi MIUI:
resolveInfo.activityInfo.name = com.miui.home.launcher.Launcher //this time I would need this
resolveInfo.activityInfo.packageName = com.miui.home //the packageName is not complete!
I need an unique identifier for the launcher! So I thought activityInfo.name would be the
way to go, but it isn't in some situations. And the packageManager seems to apply to too many devices. Any suggestions?
Cheers!
How can I get the current input device in my application in java? I want to know is the remote or the game controller, that is being used.
It is an android application that I want to run on Amazon FireTV. Unlike the Amazon Kindle there is no touchscreen but you can use a remote or a game controller. I would like to know if it is possible to detect what kind of input device the user is currently using.
The code I have until now is a standard Cordova Application code, but when I know how to detect the current input device I would make a plugin to pass the value to the javascript code. That is not the problem.
As mentioned in the comments you should provide steps you have already taken or code you have already written to address this functionality as that will help us tweak the most appropriate answer.
As a general rule, you can look at the official docs to identify controllers on Fire TV.
https://developer.amazon.com/public/solutions/devices/fire-tv/docs/identifying-controllers
Basically, you need to write the identification code in your Cordova plugin as follows:
int hasFlags = InputDevice.SOURCE_GAMEPAD | InputDevice.SOURCE_JOYSTICK;
boolean isGamepad = inputDevice.getSources() & hasFlags == hasFlags;
This will allow you to find out if it's a gamepad. For a Fire TV remote the code you need is:
int hasFlags = InputDevice.SOURCE_DPAD;
bool isRemote = (inputDevice.getSources() & hasFlags == hasFlags)
&& inputDevice.getKeyboardType() == InputDevice.KEYBOARD_TYPE_NON_ALPHABETIC;
The InputDevice class is available on the Android developer site:
http://developer.android.com/reference/android/view/InputDevice.html
So you basically need to import that in your plugin class to ensure the above code works fine.
import android.view.InputDevice;
How to detect whether the Web cam is attached to computer or not by using Java?
JMF (Java Media Framework) should be able to detect any media, including a webcam.
Potentially through CaptureDeviceManager.getDeviceList();
For "installing JMF on Linux", one way is simply to:
download it.
Change directories to the install location.
Run the command
:
% /bin/sh ./jmf-2_1_1e-linux-i586.bin
Here is a piece of code I use in a simple Webcam client with JMF:
Format format = new RGBFormat();
MediaLocator cameraLocator = null;
// get device list
Vector deviceList = CaptureDeviceManager.getDeviceList(format);
// if devices available
if(deviceList != null && deviceList.size() > 0) {
// pick first
CaptureDeviceInfo device = (CaptureDeviceInfo) deviceList.get(0);
cameraLocator = device.getLocator();
}
It picks the first available webcam. Of course, after having the webcam you can store the cameraLocator and try to re-open it on the 2nd run.