Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-web-393
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
elphel-web-393
Commits
7ec20ff4
Commit
7ec20ff4
authored
Jan 18, 2018
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved raw.php to php_top
parent
35a5345c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
120 additions
and
120 deletions
+120
-120
raw.php
src/php_top/raw.php
+33
-73
raw.php_353
src/php_top/raw.php_353
+87
-0
raw.php
src/python_tests/raw.php
+0
-47
No files found.
src/php_top/raw.php
View file @
7ec20ff4
#!/usr/local/sbin/php -q
<?php
/*!*******************************************************************************
*! FILE NAME : raw.php
*! DESCRIPTION:
*! Copyright (C) 2008 Elphel, Inc
*! -----------------------------------------------------------------------------**
*!
*! This program is free software: you can redistribute it and/or modify
*! it under the terms of the GNU General Public License as published by
*! the Free Software Foundation, either version 3 of the License, or
*! (at your option) any later version.
*!
*! This program is distributed in the hope that it will be useful,
*! but WITHOUT ANY WARRANTY; without even the implied warranty of
*! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*! GNU General Public License for more details.
*!
*! You should have received a copy of the GNU General Public License
*! along with this program. If not, see <http://www.gnu.org/licenses/>.
*! -----------------------------------------------------------------------------**
*! $Log: raw.php,v $
*! Revision 1.2 2010/02/01 20:21:46 dzhimiev
*! 1. updated the code
*! 2. added 'stop' option in order not to return the sensor in continuous mode and thus keep the raw frame in buffer
*! 3. added setting 8/16 bits for BITS
*!
*! Revision 1.1 2009/10/15 19:42:16 oneartplease
*! added raw demo files
*!
*! Revision 1.2 2008/08/18 06:00:34 elphel
*! Made it acquire one image at a time
*!
*! Revision 1.1 2008/08/18 03:27:06 kimstig
*! Raw image access demo
*!
*!
*/
$sensor_port
=
0
;
if
(
$_GET
[
'sensor_port'
]
!=
NULL
)
{
$sensor_port
=
$_GET
[
'sensor_port'
];
$BUF_SIZE
=
4096
;
$VPATH
=
"/sys/devices/soc0/elphel393-videomem@0"
$MEM_PRE
=
"
$VPATH
/membridge_start"
$VFRAME_PRE
=
"
$VPATH
/video_frame_number"
$RAWINFO_PRE
=
"
$VPATH
/raw_frame_info"
if
(
isset
(
$argv
[
1
])){
$_GET
[
'sensor_port'
]
=
$argv
[
1
];
}
function
myval
(
$s
)
{
$s
=
trim
(
$s
,
"
\"
"
)
;
if
(
strtoupper
(
substr
(
$s
,
0
,
2
))
==
"0X"
)
return
intval
(
hexdec
(
$s
));
else
return
intval
(
$s
)
;
if
(
isset
(
$_GET
[
'sensor_port'
]))
{
$sensor_port
=
$_GET
[
'sensor_port'
]
;
}
else
{
$sensor_port
=
0
;
}
$stop
=
false
;
$
parsForRaw
=
array
(
'SENSOR_RUN'
=>
1
,
'BITS'
=>
8
);
// get master
$
frame_num
=
elphel_get_frame
(
$sensor_port
);
foreach
(
$_GET
as
$key
=>
$value
)
switch
(
$key
){
case
'stop'
:
$stop
=
true
;
break
;
default
:
/// treat as camera native parameters
$parsForRaw
[
$key
]
=
myval
(
$value
);
}
$master_port
=
elphel_get_P_value
(
$sensor_port
,
ELPHEL_TRIG_MASTER
)),
0
);
$name
=
"/dev/image_raw"
;
set_buf_size
(
$sensor_port
,
$BUF_SIZE
);
set_vbuf_position
(
$sensor_port
,
0
);
// waiting for frame is built-in in the driver
copy_vbuf_to_sbuf
(
$sensor_port
,
$frame_num
+
1
);
$parsSaved
=
elphel_get_P_arr
(
$sensor_port
,
$parsForRaw
);
$thisFrameNumber
=
elphel_get_frame
(
$sensor_port
);
// read frame parameters from sysfs
// echo short header
// echo pixels
elphel_set_P_arr
(
$sensor_port
,
$parsForRaw
,
$thisFrameNumber
);
elphel_wait_frame_abs
(
$sensor_port
,
$thisFrameNumber
);
function
set_buf_size
(
$sensor_port
,
$size
){
exec
(
"echo
$size
> /sys/devices/soc0/elphel393-mem@0/buffer_pages_raw_chn
$sensor_port
"
);
}
$fp
=
fopen
(
$name
,
'rb'
);
fseek
(
$fp
,
0
,
SEEK_END
);
/// file pointer at the end of the file (to find the file size)
$fsize
=
ftell
(
$fp
);
/// get file size
fseek
(
$fp
,
0
,
SEEK_SET
);
/// rewind to the start of the file
/// send the headers
header
(
"Content-Type: application/octet-stream"
);
header
(
'Content-Disposition: attachment; '
.
'filename="image.raw"'
);
header
(
"Content-Length: "
.
$fsize
.
"
\n
"
);
header
(
"Pragma: no-cache
\n
"
);
fpassthru
(
$fp
);
/// send the raw data itself
fclose
(
$fp
);
function
set_vbuf_position
(
$sensor_port
,
$pos
){
global
$VRAME_PRE
;
exec
(
"echo
$pos
>
{
$VFRAME_PRE
}{
$sensor_port
}
"
);
}
if
(
!
$stop
)
{
$parsSaved
[
'SENSOR_RUN'
]
=
2
;
elphel_set_P_arr
(
$sensor_port
,
$parsSaved
,
$thisFrameNumber
);
function
copy_vbuf_to_sbuf
(
$port
,
$frame_num
)
{
global
$MEM_PRE
exec
(
"echo
$frame_num
>
{
$MEM_PRE
}{
$sensor_port
}
"
);
}
?>
src/php_top/raw.php_353
0 → 100644
View file @
7ec20ff4
#!/usr/local/sbin/php -q
<?php
/*!*******************************************************************************
*! FILE NAME : raw.php
*! DESCRIPTION:
*! Copyright (C) 2008 Elphel, Inc
*! -----------------------------------------------------------------------------**
*!
*! This program is free software: you can redistribute it and/or modify
*! it under the terms of the GNU General Public License as published by
*! the Free Software Foundation, either version 3 of the License, or
*! (at your option) any later version.
*!
*! This program is distributed in the hope that it will be useful,
*! but WITHOUT ANY WARRANTY; without even the implied warranty of
*! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*! GNU General Public License for more details.
*!
*! You should have received a copy of the GNU General Public License
*! along with this program. If not, see <http://www.gnu.org/licenses/>.
*! -----------------------------------------------------------------------------**
*! $Log: raw.php,v $
*! Revision 1.2 2010/02/01 20:21:46 dzhimiev
*! 1. updated the code
*! 2. added 'stop' option in order not to return the sensor in continuous mode and thus keep the raw frame in buffer
*! 3. added setting 8/16 bits for BITS
*!
*! Revision 1.1 2009/10/15 19:42:16 oneartplease
*! added raw demo files
*!
*! Revision 1.2 2008/08/18 06:00:34 elphel
*! Made it acquire one image at a time
*!
*! Revision 1.1 2008/08/18 03:27:06 kimstig
*! Raw image access demo
*!
*!
*/
$sensor_port
=
0
;
if
(
$_GET
[
'sensor_port'
]
!=
NULL
)
{
$sensor_port
=
$_GET
[
'sensor_port'
];
}
function
myval
(
$s
)
{
$s
=
trim
(
$s
,
"
\"
"
);
if
(
strtoupper
(
substr
(
$s
,
0
,
2
))
==
"0X"
)
return
intval
(
hexdec
(
$s
));
else
return
intval
(
$s
);
}
$stop
=
false
;
$parsForRaw
=
array
(
'SENSOR_RUN'
=>
1
,
'BITS'
=>
8
);
foreach
(
$_GET
as
$key
=>
$value
)
switch
(
$key
){
case
'stop'
:
$stop
=
true
;
break
;
default
:
/// treat as camera native parameters
$parsForRaw
[
$key
]
=
myval
(
$value
);
}
$name
=
"/dev/image_raw"
;
$parsSaved
=
elphel_get_P_arr
(
$sensor_port
,
$parsForRaw
);
$thisFrameNumber
=
elphel_get_frame
(
$sensor_port
);
elphel_set_P_arr
(
$sensor_port
,
$parsForRaw
,
$thisFrameNumber
);
elphel_wait_frame_abs
(
$sensor_port
,
$thisFrameNumber
);
$fp
=
fopen
(
$name
,
'rb'
);
fseek
(
$fp
,
0
,
SEEK_END
);
/// file pointer at the end of the file (to find the file size)
$fsize
=
ftell
(
$fp
);
/// get file size
fseek
(
$fp
,
0
,
SEEK_SET
);
/// rewind to the start of the file
/// send the headers
header
(
"Content-Type: application/octet-stream"
);
header
(
'Content-Disposition: attachment; '
.
'filename="image.raw"'
);
header
(
"Content-Length: "
.
$fsize
.
"
\n
"
);
header
(
"Pragma: no-cache
\n
"
);
fpassthru
(
$fp
);
/// send the raw data itself
fclose
(
$fp
);
if
(
!
$stop
)
{
$parsSaved
[
'SENSOR_RUN'
]
=
2
;
elphel_set_P_arr
(
$sensor_port
,
$parsSaved
,
$thisFrameNumber
);
}
?>
\ No newline at end of file
src/python_tests/raw.php
deleted
100644 → 0
View file @
35a5345c
<?php
$BUF_SIZE
=
4096
;
$VPATH
=
"/sys/devices/soc0/elphel393-videomem@0"
$MEM_PRE
=
"
$VPATH
/membridge_start"
$VFRAME_PRE
=
"
$VPATH
/video_frame_number"
$RAWINFO_PRE
=
"
$VPATH
/raw_frame_info"
if
(
isset
(
$argv
[
1
])){
$_GET
[
'sensor_port'
]
=
$argv
[
1
];
}
if
(
isset
(
$_GET
[
'sensor_port'
])){
$sensor_port
=
$_GET
[
'sensor_port'
];
}
else
{
$sensor_port
=
0
;
}
// get master
$frame_num
=
elphel_get_frame
(
$sensor_port
);
$master_port
=
elphel_get_P_value
(
$sensor_port
,
ELPHEL_TRIG_MASTER
)),
0
);
set_buf_size
(
$sensor_port
,
$BUF_SIZE
);
set_vbuf_position
(
$sensor_port
,
0
);
// waiting for frame is built-in in the driver
copy_vbuf_to_sbuf
(
$sensor_port
,
$frame_num
+
1
);
// read frame parameters from sysfs
// echo short header
// echo pixels
function
set_buf_size
(
$sensor_port
,
$size
){
exec
(
"echo
$size
> /sys/devices/soc0/elphel393-mem@0/buffer_pages_raw_chn
$sensor_port
"
);
}
function
set_vbuf_position
(
$sensor_port
,
$pos
){
global
$VRAME_PRE
;
exec
(
"echo
$pos
>
{
$VFRAME_PRE
}{
$sensor_port
}
"
);
}
function
copy_vbuf_to_sbuf
(
$port
,
$frame_num
){
global
$MEM_PRE
exec
(
"echo
$frame_num
>
{
$MEM_PRE
}{
$sensor_port
}
"
);
}
?>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment