We are about to switch to a new forum software. Until then we have removed the registration on this forum.
what im looking to do is run face detection on the right side of the window only not display the cam on the right side while processing on the left side which is whats happening.
void setup() {
size(1280, 480, P3D);
video2 = new Capture(this, 1280/2, 480, "webcam");
opencv = new OpenCV(this, 1280/2, 480);
opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);
video2.start();
}
void R()
{
scale(1);
opencv.loadImage(video2);
image(video2, 1280/2, 0);
noFill();
stroke(0, 255, 0);
strokeWeight(1);
Rectangle[] faces = opencv.detect();
for (int i = 0; i < faces.length; i++) {
rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
}
}
Answers
this is placing the cam on the right side, no?
should be
and here in the command rect you want to add
1280/2
@Jai -- You are drawing your video at an offset of 640:
But your faces[i] calls are returning coordinates in terms of the video -- assuming the video is starting at 0,0 -- not at 1280/2,0.
So you either need to add 640 to the "x" of each rect, in order to bump them over...
Or, perhaps better, use "translate(x,y)" to move both the video and the rects. If you need to draw more things after that are not translated, you can additionally use pushMatrix() / popMatrix() to isolate the translation and then undo it later.
edit: fixed code typo
@jeremydouglass thanks but i do not understand tho i will say that i did try
as well as
but nothing idid notice a change but not what you ended up showing me, should i have done
or something like that?
well as in now with your code i get this after 3 seconds of the program starting
one missing }
@Chrisir thanks that did the trick, now noticed how we just did R();?ok well now that this is working im going to do the same rewrite on the setup and build a second function for the 2nd cam which will be known as L(); with video1 but here idont get 2 cams just one, any tips?
in theory use the list of cameras
https://www.processing.org/reference/libraries/video/Capture.html
not sure how to tell this to opencv though
im picking those two types at the end respectfully,
i just get one left side all black and one right side on being video2 while video1 in left side remain dark
Brainstorm: Are those two at the end really different cameras, or are they the same physical camera offering different resolutions?
hope this helps guys.
https://forum.Processing.org/two/discussion/16435/how-to-make-the-webcam-capture-window-go-away-or-put-images-over-it
@GoToLoop im sorry what now? i took a look at this code
however altho i see whats going on here i just dont see how this solves or helps with my issue?
this is what i get in return for the code above
Chosen Cam #1: name=USB2.0 PC CAMERA,size=640x480,fps=30 Cam's FPS: 30.0 Canvas's FPS: 35.0 Cam's size: 640 x 480 Canvas's size: 640 x 480
It won't fix your code b/c it's got multiple issues. But it's a start! >-)
Compare my and your captureEvent() callbacks for example. Their signatures...
Also look up its reference: https://Processing.org/reference/libraries/video/captureEvent_.html
You should read about its API in order to use it correctly:
https://Processing.org/reference/libraries/video/index.html
@GoToLoop API?
and are you saying to not do this
but rather do this?
or you mean
because i tried all oh these variations and nothing or then again i may have just missed understood your reply
Just this:
Otherwise the Capture instances won't find that out! :-SS
It's gotta follow the method signature the library expects so. :-B
@GoToLoop but isnt that only calling one instance capture ? im looking to call 2
This next is from: https://processing.org/reference/libraries/video/captureEvent_.html
Unfortunately they didn't provide an example for capture. However there is a parallel example that you could try which you can find dealing with movies:
https://processing.org/reference/libraries/video/movieEvent_.html
I hope this helps,
Kf
@GoToLoop Are you saying that the movieEvent() example in the video reference is wrong?
On the other hand, notice I am quoting directly from the reference. However the reference is not clear about how to proceed:
This is to clarify. I have never manipulated two capture devices simultaneously although I would be interested to know how to do it.
Kf
Well, you can read I said it was redundant, not wrong.
Meaning it was teaching an unnecessary procedure as if it was obligatory. Spreading superstition!
I've ranted it many times in this forum for many years already:
Processing's web reference is fulla errors, superstitions & omissions! X(
Especially when the word "must" is abusively uttered there! [-(
There are times which we may need to know which particular instance was triggered.
However, never to merely call read()! :O)
Seeing is believing! Why don't you pick up that ignorant example and watch how it works? :-\"
Here, I've modified that to use that "transit.mov" file used in most of its examples.
Of course you can replace that for another video, be it the same or different 1s.
Also there are 2 movieEvent() functions. 1 of them is commented out.
You'll see w/ your own eyes that it works w/ just
m.read();
. \m/hey guys just to be clear cuz i keep hearing about this .mov and its event calls, this is somehow can be adaptive to work with my live feed from my 2 usb webcams right? or are you guys simply trying to come clear on the fact that one single even call can be enough to trigger a capture event from both of my cams when called?
The same principle applied to movieEvent() is applicable to captureEvent().
After all, they belong to the same video library: :bz
https://Processing.org/reference/libraries/video/index.html
ok good point . so basically my code is good there is something else preventing my 2 cams from being played at the same time but what can it be?
Why don't you try to write a sample code just to deal w/ 2 cams?
Mixing complex libraries just make things much harder to debug! :-&
what you mean? im only using processing, i could just add opencv later still same results
Can't you adapt my latest 2 movies at the same time example to use 2 web cams instead? :-/
no because it is expecting a .mov file to play, further more the event calls are also looking to play not read, "Reads the current frame" there will be 30fps available every second if this call is on looking for a return true if there is something to read which in fact theres always something to read its 2 live feeds you kno?
Capture class doesn't play files, but gets its feed from a camera! =P~
Of course, in order to adapt a Movie example to a Capture 1, each video file is replaced by a cam feed!
@GoToLoop as you asked me to try, i did and no results..... AND as for your recent comment i actually tried and ide told be that i cannot do what im asking because i cannot convert one into the other.
Hmm... I don't see the captureEvent() callback there! :|
yeah i forgot to go that much down on the copy nd paste i got upset that still no result despite what i try,
i got this red msg now
@GoToLoop i got that as i notice that the window ran but no feed so i closed it and then i got that msg in console
@GoToLoop i even tried this code and nothing.
I don't have 2 actual physical cameras in my laptop here.
So this sketch doesn't work for me. But I believe it may for ya if you adjust the 2 cams' index.
Pay attention on how very few lines were modified. It's almost the same as the Movie 1: $-)
For comparison, here's the original example sketch: ;;)
Try this:
https://forum.processing.org/two/discussion/5960/capturing-feeds-from-multiple-webcams
http://stackoverflow.com/questions/34206480/capture-video-from-multiple-cameras-in-processing
From this last link:
Kf
im getting this msg in the console
Have you chosen the 2 correct indices as each Capture controls 2 distinguished hardware cameras?
Like for example 1 & 11? (:|
I've already mentioned I've only got 1 physical camera in my laptop.
So I can't have more than 1 Capture here. You've gotta test it in your own hardware! 8-|
@kfrajer i fixed your code but at the end it fails to produce what we been talking about, i think my code works just fine i just think any other attempts to rewrite the same algorithm is still going to bring up those msg's i been getting, maybe thats why no one has done this lol ? i will keep trying tho its been 9 months since i been on here asking about this
@GoToLoop yes thats the first thing i did in fact i been trying for array [4] & [48]
Have you even tried my own attempt solution using the indices 1 & 11?
If you don't test my unmodified code, how can I know it works, since I don't have the means to test it out myself? [-(
Gonna repeat it here, but w/ indices 1 & 11 instead: >-)
@Jai Some relevant posts although a bit old:
https://forum.processing.org/two/discussion/3090/gstreamer-critical-2360
https://forum.processing.org/one/topic/unable-to-read-big-videos-with-processing-2-0-3.html
Unfortunately I can't helpmuch more atm bc I don't have two capture devices either. I might try something tomorrow but I can't promise anything.
Only if you could try with another camera as it is possible it could be a hardware issue. unless you happen to have a diff cam around...
Kf
Try lower resolution and using the same frameRate. This is just a guess. Also try only having two cameras connected at the time if possible. Don't use an USB hub as described in the link (in case you are using one). Try setting your cameras' resolutions to 160x120 and 30fps (or 15 fps if available).
Kf
Lowest res & fps pair is: 18 & 36. :-/
thanks guys i really appreciate your help and tips, ill keep working and i will order new cam altho coming from china they will take a while so i guess till then ill keep in touch with hopefully mind blowing results ! thnks again!!
i do have another project i been working on and will tend that one for now keep my ass debugging till new years lol
@Jai
I just tested both codes and they worked.
I tested using the following settings for both cameras: 320x240 30fps and 640x480 30fps.
Here I have attached the reference codes:
This next one tested as well from @GoToLoop's:
Kf