adobe air, detect when a webcam is unplugged? - air

I have tried to check activity, fps, status. nothing is triggered when an active camera is unplugged in as3/air. Has anyone found a working way? In my case i have a kiosk running air 2.7 running two webcams. In some cases a usb webcam might be unplugged and plugged back in. I have been trying find a way to detect when its unplugged so I can restart it. Ideas?

Unfortunately i have no USB camera to test this with (only got insight).
You could try ActivityEvent and set motionlevel to some low value.
ActivityEvent will give you response if and when motion is detected in camera. I belive when Camera is physically disconnected, activity event should trigger since no activity will be detected.
Here's a piece of example:
import flash.media.Camera;
import flash.display.Stage;
import flash.media.Video;
import flash.events.ActivityEvent;
import flash.events.StatusEvent;
var camera:Camera = Camera.getCamera();
camera.setMode(stage.stageWidth, stage.stageHeight,25);
camera.addEventListener(ActivityEvent.ACTIVITY, activityEventHandler,false,0,true);
camera.setMotionLevel(3);
var video:Video = new Video();
video.width = stage.stageWidth;
video.height = stage.stageHeight;
video.attachCamera(camera);
addChild(video);
function activityEventHandler(a:ActivityEvent):void{
trace('Motion detected: '+a.activating);
}
Note:
setMotionlevel default value is 50 so if you set it to eg. 3 then camera still notices some small changes, even eye-blinking. That would help you to detect if there is any kind of motion at all. If no motion is detected then camera is probably dead.
You maybe even can use motionlevel as 1, but this value is very sensitive and even slightest change in room lightning is probably detected as motion.
Let me know if that helps, would be interesting to hear about this in practice with real USB camera.

Related

Use getDisplayMedia to record the screen, when the microphone is added from the system, there is no sound!

In chrome browser, I am using MacBook to record a 30 minutes class, in code, use getDisplayMedia to get the screen stream:
navigator.mediaDevices.getDisplayMedia({audio:true,video:true}).then((mediaStream)=>{
mediaRecorder = new MediaRecorder(mediaStream,{mineType:'video/webm'})
})
2.When the recording started 5 minutes later, I connected an external microphone to the MacBook, then lectured through the microphone, and then hoped that my voice would be recorded through the microphone, but the strange thing is that since the microphone is connected, there is no recording screen behind The sound is down, what’s the matter, how can I operate so that I can continue recording when switching microphones?

Take pictures using camera shutter when receiving live view data

I am developing using EDSDK.
However, if I press the shutter of the camera (physical button) while receiving live view data(EVF Mode), the picture won't be taken. Is this normal?
My camera model is 200D II.
What I'm trying to do is as follows, and it's very simple.
My software activates the camera through EDSDK and receives live view data.
The person behind the camera takes a picture by pressing the camera shutter, and my software shows the picture on the screen.
The questions are as follows.
How to take pictures using physical camera shutter buttons when receiving live view data(EVF).
HDMI connections are not considered because there are features that need to be controlled directly through EDSDK.
Thank you.
Below is what I added after Johannes Bildstein's answer.
As Johannes Bildstein answered, the following code was inserted to unlock the UI.
But it still hasn't been solved.
if (!MainCamera.IsLiveViewOn) {
MainCamera.StartLiveView();
MainCamera.UILock(false);
}
Error message occurs when I try to unlock UI and get EVF data. (Shutter still doesn't work)
If I unlock UI after receiving EVF data,
When dial is in photo mode: EVF data is coming in, but the shutter still does not work.
When dial is in video mode: EVF data does not come in due to BUSY error. Is it a conflict due to UI unlocking? We check your answers and SDK documents and try in many ways, but they are still unresolved. We are currently testing the more recent model, 200D II.
"| EvfOutputDevice.Camera " should be added like below!
public void StartLiveView()
{
CheckState();
if (!IsLiveViewOn) SetSetting(PropertyID.Evf_OutputDevice, (int)(EvfOutputDevice.PC | EvfOutputDevice.Camera ));
}
The camera "UI" is probably locked. The EDSDK does that automatically when connecting and before doing certain commands. You can unlock it with EdsSendStatusCommand using kEdsCameraStatusCommand_UIUnLock.

How to switch local video without switching audio in a webrtc conference?

I have two or more cameras connected to my pc. My goal is, to switch between the local cameras in an ongoing webrtc videoconference - but only to switch video from camera 1 to camera 2 NOT audio. Audio should always come from camera 1.
How to toggle between the two videoTracks?
See this answer.
Basically you can use replaceTrack() in Firefox to do this today for a seamless replacement of a camera. This is being added to the spec, but Chrome doesn't support it yet.
The best you can do in Chrome today is to get a new stream with the same mic but a different camera, remove the old stream/tracks from the PeerConnection and add the new one, and then handle onnegotiationneeded and renegotiate. This will likely cause a glitch, and will require at least a couple of round-trip-times to complete. (This will work in Firefox as well.

Liveview on Android/QX1 Sony Camera API 2.01 fails

Using the supplied Android demo from
https://developer.sony.com/downloads/all/sony-camera-remote-api-beta-sdk/
Connected up to the WIFI connection on a Sony QX1. The sample application finds the camera device and is able to connect to it.
The liveview is not displaying correctly. At most, one frame is shown and the code hits an exception in SimpleLiveViewSlicer.java
if (commonHeader[0] != (byte) 0xFF) {
throw new IOException("Unexpected data format. (Start byte)");
}
Shooting a photo does not seem to work. Zooming does work - lens is moving. Camera is working fine when using the PlayMemories app directly, so no hardware issue.
Hoping from advice from Sony on this one - standard hardware and demo application should work.
Can you provide some details of your setup?
What version of Android SDK are you compiling with?
What IDE and OS are you using?
Have you installed the latest firmware? (http://www.sony.co.uk/support/en/product/ILCE-QX1#SoftwareAndDownloads)
Edit:
We tested the sample code using a QX1 lens and the same setup as you and were able to run the sample code just fine.
One thing to check is whether the liveview is ready to transfer images. To confirm whether the camera is ready to transfer liveview images, the client can check “liveviewStatus” status of “getEvent” API (see API specification for details). Perhaps there is some timing issue due to connection speed that is causing the crash.

Deciding if external display is activated or not

I'd like to be able to decide if the display on the computer where my app is running is currently active or shutdown. I need this for a media center software so I know if I need to activate the display before starting the playback of movies.
So far I tried to use this code:
CGError err0 = CGDisplayNoErr;
CGError err1 = CGDisplayNoErr;
CGDisplayCount dspCount = 0;
err0 = CGGetActiveDisplayList(0, NULL, &dspCount);
CGDisplayCount onlineCount = 0;
err1 = CGGetOnlineDisplayList(0, NULL, &onlineCount);
// Error handling omitted for clarity ;)
NSLog(#"Found %d active and %d online displays", dspCount, onlineCount);
But this code out puts always the same. When I try it on my mac mini, with the display turned off I get the following output:
Found 1 active and 1 online displays
The display is not in a standby mode as I disconnect the power to it when it is not in use. I also tried this on my mac book, which has an internal and an external display. And there it returns:
Found 2 active and 2 online displays
Here it is the same, I deactivate the display and disconnect the power to it but is still returns as beeing active.
The display on the mac mini is a tv-set connected with a dvi to hdmi cable. The display on the mac book is connected with a dvi to vga connector.
I hope somebody has an idea how to solve this. Thanks in advance.
It sounds like you want to know whether any connected display is asleep or not?
Have you looked at the CGDisplayIsAsleep function?
http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/Quartz_Services_Ref/Reference/reference.html#//apple_ref/c/func/CGDisplayIsAsleep
To close this open question. My final findings were that as soon as an external monitor is connected to the computer the given methods will return that it is there. And this also works when the monitor is powered of and not connected to the power source.
So as far as I can tell there is no way to find out what I would like to know :(
As I control the event which activates the monitor from my application (in my case its a TV which I control with a usb to ir box) I can get the state of the monitor in this way, but this only has the downside that when the application is crashing, I will lose the state. But thats the best solution I could find.