interfacing OpenCV with php - php

I have an executable file developed using opencv library in cpp and c also. I want to execute it from my website hosted on localhost using a php script.
The problem i'm facing is that, the executable code opens a window(kind of gui, opened using namedWindow) when called from terminal but it doesn't do that when called from the embedded php script.
For execution i have tried exec, system but all these failed.
to be more clear : name of executable -> my_cv_gui, name of phpscript(page) ->abcd.php
#terminal if i type "./my_cv_gui" ... window opens.
# terminal, if itype "php abcd.php" window opens
abcd.php is part of my website. In web browser if i open "http://...../abcd.php", window DOESNOT open. Although other things in the executable work perfectly.
My system configuration
OS : ubuntu 12.04 x64
XAMPP for Linux 1.7.7
Apache 2.2.21
PHP 5.3.8
Opencv 2.4.1
Any solutions??
The php code is as follows
<?php
$output=shell_exec("gst-launch v4l2src device=/dev/video0 ! 'video/x- raw-yuv,width=640,height=480,framerate=30/1' ! ffenc_flv ! flvmux streamable=true ! queue ! filesink location=/home/dev/my.avi > /dev/null &");
var_dump($output);
?>

Two things you should always remember when you are working with apache.
File/Folder Permission. Using which the apache is running.
MIME type should be added to apache to run any kind of multimedia components. Like here it's flv. Then try running the php code and try fixing it. I will check in my server if that works for me. Will update you.
Biswadip.

Related

PHP is not working on Windows after I completely installed it

I am trying to setup php 5.5.12 on my Windows server 2008 R2
I found this good tutorial that walks you step by step
http://www.youtube.com/watch?v=WUoqkPJEp4Y
After completing every step everything seems to be fine.
I created a file called phpinfo.php and put the following code into and placed it on c:/inetpub/wwwroot
<?php php_info(); ?>
But when I got localhost/phpinfo.php or http://127.0.0.1:80/phpinfo.php I get a 404 error. I do not know why it is not working. when I execute the following from commands from the command line it looks like it is working and I get many output with no error.
cd c:/php
php -i
In addition to the instruction, I added the following to the registry of windows
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\PHP]
"IniFilePath"="C:\\PHP"
Can someone tell me what else do I need to make get php up and running on windows?
This is what is using port 80 on my server
To use localhost or 127.0.0.1 you need apache installed on your system too.
You can download xampp or wamp they both come with PHP, MySql & Apache installed in them.

No ssl on php commandline

I have a php script that works perfectly on the browser BUT it has this error on windows command line.
I have ssl enabled in php config and from what I gather it works for browser but not command line but I don't understand the difference between these two (neither is windows service I belive). Basicly I don't know what to do about it and I need to run the script from commandline, then create .bat file (in order to start windows scheduler - like cron under linux).
I have windows Xp and Xampp. Please help.
As mentioned in comment above. Php in command line uses different php.ini config.

R script in php

I am running the php script containing Rscript in terminal. its working fine and giving the output. but the same script if i call from the webpage its not giving any output. i have checked the folder permission also. please help me to fix this.
my php script:
<?php
$abc=exec('Rscript dist/GS_R2html.R');
print "$abc\n";
?>
Rscript:
a<-rnorm(1000)
library(R2HTML)
setwd('/var/www/test')
HTML.title("Data Summary", file="dist/gshtml.htm",append=F)
HTML(summary(a),file="dist/gshtml.htm",align="left")
HTML(matrix(a[1:100],nrow=10,byrow=T),file="dist/gshtml.htm",align="left")
HTML.title("Histogram", file="dist/gshtml.htm")
jpeg("dist/plot2.jpg")
hist(a,col="red")
HTMLInsertGraph("dist/plot2.jpg",file="dist/gshtml.htm",Align="left")
dev.off()
Its due to the missing of the rApache which supports web application development using the R and the Apache web server. I followed the steps mentioned in the http://rapache.net/manual.html to install and configure R in Apache.

popen() gives error: no such file or directory

I am using php version 5.2.17. I have a site build in php and testing it under IIS 5.1 on localhost (windows).
I want to run a lengthy PHP script in background, thereby allowing the user to continue using the site (navigation).
I am trying using popen like this:
$cmd='c:\\php\\php.exe c:\\inetpub\\wwwroot\\download.php';
pclose(popen('start /B '.$cmd, 'r'));
This gives error:
PHP Warning: popen(c:\php\php.exe C:\inetpub\wwwroot\download.php,r) [function.popen]: No such file or directory.
Any clues are highly appreciated.
Try to first execute cmd and then call php over cmd like explained here: http://bytes.com/topic/php/answers/751763-popen-windows
SOLVED: i changed the file security of Download.php in IIS and set the user to IWAM(launch IIS Process account).
Thanks for ull experts who showed concern.

how to run a batch file in php under xampp on windows

I'm trying to write a little php to update an svn repo on a server running xampplite under windows. (This is a development server, not a production one.)
Here's my php:
<?php
passthru("update.bat");
// I also tried exec() & putting the svn command in directly
?>
update.bat is sitting in the same folder as the php script
Here's the content of update.bat:
svn up c:\path\to\my\repo
When I run the batch file by itself, it works. When I run it via php, I get this printed to the browser:
C:\path\to\script\folder>svn up c:\path\to\my\repo
which looks good, but the project isn't updated.
Adding the username and password to the batch made the difference. Here's the new update.bat:
svn up --username <usr> --password <pwd> c:\path\to\the\repo
Try this tip on php.net/function.exec
The other option is to manually compile the php svn extension (there's no Windows DLL), but you also need the svn libraries first.

Categories